-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInjector.py
43 lines (36 loc) · 1.26 KB
/
Injector.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# coding: utf-8
import socket, threading,select
def conecta(cliente, endereco):
print('Cliente {} Recebido'.format(endereco))
servidor = socket.socket()
servidor.connect( ( '34.95.212.133', 443) )
cliente.recv( 8192 )
servidor.send( b'CONNECT 34.95.212.133:80 HTTP/1.0\r\n\r\n')
servidor.recv( 8192 )
cliente.send(b'HTTP/1.1 200 SSHPLUS\r\n\r\n')
try:
while True:
leitura, escrita, erro = select.select( [ servidor, cliente ], [], [servidor, cliente ], 3)
if erro: raise
for i in leitura:
dados = i.recv( 8192 )
if not dados: raise
print(dados)
if i is servidor:
# Download
cliente.send( dados )
else:
# Upload
servidor.send( dados )
except:
print('Cliente Desconectado')
def conn_client():
listen = socket.socket()
listen.bind( ( '127.0.0.1', 8088) )
listen.listen( 0 )
print('Esperando o Cliente no IP e Porta: 127.0.0.1:8088')
while True:
cliente, endereco = listen.accept()
threading.Thread(target = conecta, args = ( cliente, endereco) ).start()
if __name__=="__main__":
conn_client()