π΄CTF/WeChall
WeChall - Training: Net Ports
Janger
2023. 2. 16. 12:31
728x90
νμ¬ νμ΄μ§μμ 42λ² ν¬νΈλ‘ μ μμ νλΌκ³ νλ€.
μλμλ νμ¬ λ΄κ° μ μν ν¬νΈ λ²νΈκ° μ νμμΌλ©° μ΄λ λ§€λ² μλ‘ κ³ μΉ¨ ν λλ§λ€ λ°λ μ μλ€.
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.poolmanager import PoolManager
class SourcePortAdapter(HTTPAdapter):
""""Transport adapter" that allows us to set the source port."""
def __init__(self, port, *args, **kwargs):
self._source_port = port
super(SourcePortAdapter, self).__init__(*args, **kwargs)
def init_poolmanager(self, connections, maxsize, block=False):
self.poolmanager = PoolManager(
num_pools=connections, maxsize=maxsize,
block=block, source_address=('', self._source_port))
s = requests.Session()
s.mount('http://', SourcePortAdapter(42))
s.mount('https://', SourcePortAdapter(42))
res = s.get("https://www.wechall.net/challenge/training/net/ports/index.php", cookies={"WC":"μμ μ_μΏ ν€"})
print(res)
λκ΅°κ° νμ΄μ¬μΌλ‘ μμ€ ν¬νΈλ²νΈλ₯Ό μ€μ ν μ μλ μμ€ μ½λλ₯Ό μ¬λ¦°κ² μμ΄μ μ΄λ₯Ό μμ ν΄μ μ¬μ©νλ€.
μΆμ²:
Python Requests, how to specify port for outgoing traffic?
I'm working on a project where we want to assign a whitelist packet filters for incoming traffic on a firewall and we are using python script with requests library to make some https requests to some
stackoverflow.com
728x90