메뉴 건너뛰기

Hello :0

import socket

def socket_request():
    host = "192.168.0.1"
    port = 80
    bufsize = 4096
    
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.connect((host, port))
    
    sock.send("GET / HTTP/1.1 \r\nHost: 192.168.0.1\r\nConnection: close\r\n\r\n")
    print(sock.recv(bufsize))
    
    sock.close()
    
socket_request()

socket 함수

테스트 할때 간단하게 트래픽 요청

 

import httplib
payload="""
        Test
        """
headers = {"User-Agent":"kSOAP/2.0",
           "SOAPAction":"",
           "Content-Type":"text/xml",
           "Connection":"close",
           "Host":"192.168.0.1:8080",
           "Accept-Encoding":"gzip"}
conn=httplib.HTTPConnection("192.168.0.1:8080")
conn.request("POST","/",payload)
response = conn.getresponse()
#print response.status, response.reason 200 OK
data = response.read()
print data
conn.close()

라이브러리 사용

 

import socket
 
def socket_request():
    host = "192.168.0.1"
    port = 80
    bufsize = 4096
     
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.connect((host, port))
     
    sock.send("PUT /test.txt HTTP/1.1\r\nHost: 192.168.0.1\r\nConnection: close\r\nContent-Length: 5\r\n\r\nhello\r\n\r\n")
    print(sock.recv(bufsize))
     
    sock.close()
     
socket_request()

 

 

POC나 모의 해킹 테스트 할떄 간혹 필요한