한번에 HTTP Request 를 할일이 있을때 것두 많이 ㅋ
한번에 세션을 무진장 많이 만들어 볼일이 있었는데 ㅋ
쓰레드로 한번 짜봤음 ㅋ
저기서 close 안하고 recv도 계속 대기 타게 만들면 dos 툴이 되려나?ㅋㅋㅋ
#!/usr/bin/python
#ref : http://bloodguy.tistory.com/365
import thread
import time
import socket
import ssl
import sys
import os
v_lock = thread.allocate_lock()
v_max_thread = 1111
def F_TCP_SEND(lv_addr, lv_port, lv_msg_send):
lv_msg_recv=''
try:
lv_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
lv_sock.connect((lv_addr,lv_port))
lv_sock.send(lv_msg_send)
lv_msg_recv = lv_sock.recv(0)
lv_sock.close()
except:
print '\n[F_TCP_SEND]'+str(sys.exc_info())
return lv_msg_recv
#def
def F_TCP_SSL_SEND(lv_addr, lv_port, lv_msg_send):
lv_msg_recv=''
try:
lv_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
lv_sock.connect((lv_addr,lv_port))
lv_sock_ssl = ssl.wrap_socket(lv_sock)
lv_sock_ssl.send(lv_msg_send)
lv_msg_recv = lv_sock_ssl.recv()
lv_sock_ssl.close()
lv_sock.close()
except:
print '\n[F_TCP_SSL_SEND]'+str(sys.exc_info())
return lv_msg_recv
#def
def F_THREAD_FLAG():
v_lock.acquire()
global v_max_thread
v_max_thread=v_max_thread-1
v_lock.release()
#def
def F_TCP_ONLY(lv_idx):
lv_msg_send=('a'*1400)
F_TCP_SEND('192.168.0.1',80, lv_msg_send)
F_THREAD_FLAG()
#def
def F_TCP_HTTP(lv_idx):
lv_msg_send = 'GET / HTTP/1.1\nHost: 192.168.0.1\nUser-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:20.0) Gecko/20100101 Firefox/20.0\nAccept: */*\nAccept-Language: en-US,en;q=0.5\nAccept-Encoding: gzip, deflate\nDNT: 1\nReferer: http://192.168.0.1/\nCookie: %s\nConnection: keep-alive\n\n'%('a'*1134)
F_TCP_SEND('192.168.0.1',80, lv_msg_send)
F_THREAD_FLAG()
#def
def F_TCP_SSL(lv_idx):
lv_msg_send=('a'*700)
F_TCP_SSL_SEND('192.168.0.1',443, lv_msg_send)
F_THREAD_FLAG()
#def
def F_TCP_HTTPS(lv_idx):
lv_msg_send = 'GET / HTTP/1.1\nHost: 192.168.0.1\nUser-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:20.0) Gecko/20100101 Firefox/20.0\nAccept: */*\nAccept-Language: en-US,en;q=0.5\nAccept-Encoding: gzip, deflate\nDNT: 1\nReferer: http://192.168.0.1/\nCookie: %s\nConnection: keep-alive\n\n'%('a'*500)
F_TCP_SSL_SEND('192.168.0.1',443, lv_msg_send)
F_THREAD_FLAG()
#def
# os.system('ulimit -n 102400')
print 'start making thread'
ix=0
try:
for ix in range(v_max_thread):
#thread.start_new_thread(F_TCP_ONLY,(ix,))
#thread.start_new_thread(F_TCP_HTTP,(ix,))
#thread.start_new_thread(F_TCP_SSL_SEND,(ix,))
thread.start_new_thread(F_TCP_HTTPS,(ix,))
#if ix%10000==0:
#time.sleep(1)
#print ix
#for
except:
v_max_thread = ix
v_max_thread = ix
print 'All done, making thread(%d)'%v_max_thread
while v_max_thread:
time.sleep(0.1)
#while
print 'All done, process exit'
0개의 덧글:
댓글 쓰기
에 가입 댓글 [Atom]
<< 홈