🏴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)

λˆ„κ΅°κ°€ 파이썬으둜 μ†ŒμŠ€ 포트번호λ₯Ό μ„€μ •ν•  수 μžˆλŠ” μ†ŒμŠ€ μ½”λ“œλ₯Ό 올린게 μžˆμ–΄μ„œ 이λ₯Ό μˆ˜μ •ν•΄μ„œ μ‚¬μš©ν–ˆλ‹€. 

 

 

좜처: 

https://stackoverflow.com/questions/47202790/python-requests-how-to-specify-port-for-outgoing-traffic

 

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