def send_nudes(self):
        """
        sends whoami to Johyn
        """
        addr = translator.Address()
        addr.create()

        payload = translator.Whoami()
        payload.create(1, addr, 2, [translator.Var_str("node")])
        paie = payload.encode()
        l = len(paie)
        #print(list(ord(c) for c in paie))

        c = translator.Whoami()
        c.decode(paie)
        #print(c)

        #print(list(hex(ord(c)) for c in paie))

        a = translator.Message()
        a.create("whoami", l, paie)
        message = a.encode()

        print(list(hex(ord(c)) for c in message))
        #print(list(hex(c) for c in message.encode()))

        b = translator.Message()
        b.decode(message)
        print(b)

        c = translator.Whoami()
        #print(list((ord(c)) for c in str(b.payload)))
        c.decode(str(b.payload))
        print(c)

        #TCP_IP = "192.168.0.10"
        #TCP_IP = "78.248.188.120"
        TCP_IP = socket.gethostname()
        TCP_PORT = 4224

        name = "{}:{}".format(TCP_IP, TCP_PORT)

        self.start_connexion(TCP_IP, TCP_PORT)
        self.send(name, message)
        print(self.listen_timed(name))
        #self.end_connexion(name)

        paie = ""
        l = 0
        a = translator.Message()
        a.create("whoamiack", l, paie)
        message = a.encode()
        self.send(name, message)
        print(self.listen(name))
예제 #2
0
def whoamiack():
    paie = ""
    l = 0
    a = translator.Message()
    a.create("whoamiack", l, paie)
    message = a.encode()

    return message
 def send_nudes(self):
     """
     sends whoami to Johyn
     """
     addr = translator.Address()
     addr.create()
     
     payload = translator.Whoami()
     payload.create(4,addr,1,[translator.Var_str("say whoami")])
     paie = payload.encode()
     l = len(paie)
     
     c = translator.Whoami()
     c.decode(paie)
     #print(c)
     
     #print(list(hex(ord(c)) for c in paie))
     
     a=translator.Message()
     a.create("whoami",l,paie)
     message = a.encode()
     #print(list(hex(ord(c)) for c in message))
     
     b=translator.Message()
     b.decode(message)
     print(b)
     
     c = translator.Whoami()
     #print(list(hex(ord(c)) for c in str(b.payload)))
     c.decode(str(b.payload))
     #print(c)
     
     TCP_IP = "78.248.188.120"
     #TCP_IP = socket.gethostname()
     TCP_PORT = 4224
 
     name = "{}:{}".format(TCP_IP, TCP_PORT)    
 
 
     print("connection established: " + str(self.start_connexion(TCP_IP,TCP_PORT)))
     print("message sent: " + str(self.send(name,message)))
     print(self.listen_timed(name))
     print("received")
     self.end_connexion(name)
예제 #4
0
def whoami():
    """
    returns a compatible whoami so it can be sent to another node
    """
    addr = translator.Address()
    addr.create()

    payload = translator.Whoami()
    payload.create(1, addr, 2, [translator.Var_str("node")])
    paie = payload.encode()
    l = len(paie)

    a = translator.Message()
    a.create("whoami", l, paie)
    message = a.encode()

    return message
예제 #5
0
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 19 10:42:00 2018

@author: julouj
"""

import socket
import translator

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((socket.gethostname(), 4223))
s.listen(3)

while True:
    (clientsocket, address) = s.accept()
    print(address)
    a = clientsocket.recv(1024)
    
    b=translator.Message()
    b.decode(a.decode())
    print(b)
    
    message = "honk"
    clientsocket.send(message.encode())
    clientsocket.close()