Add files via upload
the client that ggsya made which makes it the most pog client there is
This commit is contained in:
78
basic client CLI.py
Normal file
78
basic client CLI.py
Normal file
@@ -0,0 +1,78 @@
|
||||
import socket
|
||||
import threading
|
||||
from Crypto.Cipher import AES
|
||||
clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
||||
|
||||
def check_name(name):
|
||||
for i in name:
|
||||
try:
|
||||
int(i)
|
||||
print('there is a number in de name?!?!')
|
||||
break
|
||||
except:
|
||||
pass
|
||||
|
||||
#ip='www.ggsya.ga'
|
||||
#ip = '41.40.24.151'
|
||||
#ip = socket.getaddrinfo('ggsya.ga',9000)[0][-1]
|
||||
def default():
|
||||
ip='192.168.1.6'
|
||||
name= 'gg'
|
||||
print('trying to connect')
|
||||
clientsocket.connect((ip, 9000))
|
||||
print('connected')
|
||||
clientsocket.send(name.encode())
|
||||
check_name(name)
|
||||
|
||||
def custom():
|
||||
ip = input('ip: ')
|
||||
print('trying to connect')
|
||||
name = input('name: ')
|
||||
check_name(name)
|
||||
clientsocket.connect((ip, 9000))
|
||||
print('connected')
|
||||
|
||||
default()
|
||||
#custom()
|
||||
|
||||
|
||||
def do_encrypt(message):
|
||||
obj = AES.new('ggsyaisverypoggersholyheckhowish', AES.MODE_CBC, 'poggers')
|
||||
ciphertext = obj.encrypt(message)
|
||||
return ciphertext
|
||||
|
||||
def do_decrypt(ciphertext):
|
||||
obj2 = AES.new('ggsyaisverypoggersholyheckhowish', AES.MODE_CBC, 'poggers')
|
||||
message = obj2.decrypt(ciphertext)
|
||||
return message
|
||||
|
||||
|
||||
def recievemessage():
|
||||
while True:
|
||||
try:
|
||||
incoming_message =clientsocket.recv(1024) # try to receive 1024 bytes
|
||||
except socket.timeout:
|
||||
pass
|
||||
else:
|
||||
print(do_decrypt(incoming_message.decode()))
|
||||
|
||||
|
||||
|
||||
|
||||
def sendmessage():
|
||||
while 1:
|
||||
message = input()
|
||||
clientsocket.send(do_encrypt(message).encode())
|
||||
|
||||
|
||||
clientsocket.settimeout(0.1)
|
||||
|
||||
thread = threading.Thread(target=recievemessage)
|
||||
thread.start()
|
||||
|
||||
sendmessage()
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user