-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathutils.py
More file actions
51 lines (37 loc) · 1.13 KB
/
utils.py
File metadata and controls
51 lines (37 loc) · 1.13 KB
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
44
45
46
47
48
49
50
51
import socket
PREFIX = ""
SUFFIX = ""
encode = lambda x : bytes(x , encoding='raw_unicode_escape')
def connect_send(target, port, buffer):
try :
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(5)
print("[!] Connecting to {} {}.".format(target,port))
s.connect((target,port))
#"""
print("[!] Receiving data: ")
data = s.recv(1024)
print(data)
#"""
buffer = PREFIX + buffer + SUFFIX
print("[!] Sending buffer of len {}.".format(len(buffer)))
s.send(encode(buffer))
#"""
print("[!] Receiving data: ")
data = s.recv(1024)
print(data)
#"""
print("[!] Closing socket.\n\n")
s.close()
except Exception as e :
print("Error: {}\n\n".format(e))
return True
return False
def get_answer(answer) :
while True :
if answer.lower() == "no" or answer.lower() == "n" :
return False
elif answer.lower() == "yes" or answer.lower() == "y" :
return True
else :
answer = input("(yes/no): ").strip()