선 밖에 선 자유인

간단한 python Banner Grabbing 스크립트 본문

IT/Security

간단한 python Banner Grabbing 스크립트

Hotman 2016. 11. 1. 15:02
#!/usr/bin/python

import sys
import socket

target = str(sys.argv[1])
port = 80
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((target, port))

s.send("OPTIONS / HTTP/1.1\r\nHost: www.google.com\r\n\r\n")
response = s.recv(4096)
print response

혹은
#!/usr/bin/python

import socket
import sys

# Building Socket
af,type,proto,name,conn = socket.getaddrinfo(sys.argv[1], sys.argv[2], 0, 0, socket.SOL_TCP)[0]

s = socket.socket(af,type,proto)
s.connect(conn)
s.send("OPTIONS / HTTP/1.1\n\n")

page = ""

while 1:
	data = s.recv(1024)
	if data == "":
		break
	page = page + data

s.close()

print page
Comments