123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- import json
- import os
- import time
- class padra():
- def __init__(self,len):
- self.len = len
- print("added",self.len)
- def toSend(self,x):
- j = json.dumps(x)
- l = self.len - len(str(len(j)))
- return "0000"[0:l]+str(len(j))+j
- def toJson(self,x):
- print( x)
- return json.loads(x)
- # user
- def xor(self,o,key,data):
- print("startetd")
- o0data= {
- "function":"xor",
- "players_number":"3",
- "player":"0",
- "ip":"192.168.178.105",
- "data":"",
- }
- o[0].send(self.toSend(o0data))
- o1data= {
- "function":"xor",
- "players_number":"3",
- "player":"1",
- "ip":"192.168.178.105",
- "data":key,
- }
- o[1].send(self.toSend(o1data))
- o2data= {
- "function":"xor",
- "players_number":"3",
- "player":"2",
- "ip":"192.168.178.105",
- "data":data
- }
- o[2].send(self.toSend(o2data))
- def aes(self,o,key,data):
- print("startetd")
- o0data= {
- "function":"aes",
- "players_number":"3",
- "player":"0",
- "ip":"192.168.178.105",
- "data":"",
- }
- o[0].send(self.toSend(o0data))
- o1data= {
- "function":"aes",
- "players_number":"3",
- "player":"1",
- "ip":"192.168.178.105",
- "data":key,
- }
- o[1].send(self.toSend(o1data))
- o2data= {
- "function":"aes",
- "players_number":"3",
- "player":"2",
- "ip":"192.168.178.105",
- "data":data
- }
- o[2].send(self.toSend(o2data))
- print("Data send from USER")
-
- # oracle
- def parse(self,message):
- data = json.loads(message)
- print(data)
- function = data["function"]
- if(function == "aes"):
- self.aesOracle(data["players_number"],data["player"],data["ip"],data["data"])
- elif(function == "xor"):
- self.xorOracle(data["players_number"],data["player"],data["ip"],data["data"])
- def aesOracle(self,players_number,player,ip,data):
- player=int(player)
- players_number=int(players_number)
- time.sleep(player*10)
- line = " "
- t1= "echo "+ data + " > gf2n_vals.in"
- t2= "./gen_input_f2n.x"
- t3= "mv ./gf2n_vals.out ./Player-Data/Private-Input-"+str(player)
- t4= "./mascot-party.x "+str(player)+" aes_m -pn 12598 -h "+ip+" -N "+str(players_number)
- handle = (os.system("ls"))
- print (handle)
- handle = (os.system("cd .."))
- print (handle)
- handle = (os.system("ls"))
- print (handle)
- handle = (os.system(t1))
- print (line)
- handle = (os.system(t2))
- print (line)
- handle = (os.system(t3))
- print (line)
- handle = (os.system(t4))
- print (line)
-
- def xorOracle(self,players_number,player,ip,data):
- player=int(player)
- print(player)
- players_number=int(players_number)
- time.sleep(player*10)
- line = " "
- if player != 0:
- t1= "echo 1 "+ data + " > gf2n_vals.in"
- handle = (os.system(t1))
- print (line)
- if player != 0:
- handle = (os.system("./gen_input_f2n.x"))
- print (line)
- if player != 0:
- handle = (os.system("mv ./gf2n_vals.out ./Player-Data/Private-Input-"+str(player)))
- print (line)
- print("player " + str(player) )
- t4= "./mascot-party.x "+str(player)+" xor -pn 12598 -h "+ip+" -N "+str(players_number)
-
- handle = (os.system(t4))
- print (line)
|