def loginAPI():
    global internal_storage, interruptQueue
    pub_hex = request.values.get("pub_key")
    pub_key = pub_hex
    internal_storage["Public_key"] = pub_key

    priv_hex = request.values.get("priv_key")
    priv_key = priv_hex
    internal_storage["Private_key"] = priv_key

    if getNeighbours(self_address):
        # not the first one
        # request latest block as json
        current_block = requestLatestBlock()

        data = json.loads(current_block)
        tx_list = []
        for tx in data['Tx_list']:
            tx_list.append(createTxFromDict(tx))
        # build block
        b = createBlockFromDict(tx_list, data)

        # update state
        bc = blockChain.Blockchain(_block=b)
        internal_storage["Miner"] = attacker.Attacker(_blockchain=bc,
                                                      _pub=pub_key,
                                                      _priv=priv_key)

    else:
        # create first block
        internal_storage["Miner"] = attacker.Attacker(_blockchain=None,
                                                      _pub=pub_key,
                                                      _priv=priv_key)
        generator = internal_storage["Miner"].mineBlock()
        try:
            interruptQueue = next(generator)
            block_data = next(generator)
            internal_storage["Miner"].broadcastBlock(
                _block_data=block_data,
                _neighbours=internal_storage["Neighbour_nodes"],
                _self_addr=self_address,
            )
        except StopIteration:
            print("MinerApp Interrupted")

    # re-routes back to homepage
    return homePage()
示例#2
0
 def create_players(self):
     #create players
     #TODO: test if the graph has been initialized.
     _, oredges = self.get_ORedges()
     _, andnodes = self.get_ANDnodes()
     self.attacker = attacker.Attacker(
         oredges=oredges,
         andnodes=andnodes,
         actionspace=self.get_att_actionspace())
     self.defender = defender.Defender(self.G)
示例#3
0
	def run(self):
		self.banner()

		try:
			Proxynet.init("\.(js|jpg|gif|swf|ico|png|bmp|zip|rar|pdf|css|t?gz)$")
			self.at=attacker.Attacker()
			self.at.start()
			self.controller=crllr.Controller()
		except Exception,a:
			print "<<--Error-->>\r\n",a
def newUser():
    global internal_storage, interruptQueue, saved_block
    priv, pub = keyPair.GenerateKeyPair()
    internal_storage["Private_key"] = priv.to_string().hex()
    internal_storage["Public_key"] = pub.to_string().hex()

    newUser = open("Newuser.html").read()

    info = "Public Key: {}<br>" \
    "Private Key: {}<br>" \
    "Please save these 2 (They are unrecoverable)".format(
        pub.to_string().hex(),
        priv.to_string().hex()
    )

    pub_key = internal_storage["Public_key"]
    priv_key = internal_storage["Private_key"]

    internal_storage["Miner"] = attacker.Attacker(_pub=pub_key, _priv=priv_key)

    # announce yourself
    getNeighbours(self_address)
    generator = internal_storage["Miner"].mineBlock()

    try:
        interruptQueue = next(generator)
        block_data = next(generator)
        internal_storage["Miner"].broadcastBlock(
            _block_data=block_data,
            _neighbours=internal_storage["Neighbour_nodes"],
            _self_addr=self_address,
        )
        if saved_block is None:
            print("Saving Block...")
            saved_block = block_data

    except StopIteration:
        print("AttackerApp New Interrupted")

    return info + newUser
示例#5
0
# toggle whether the given network @ address is accessable or not
def toggle_network(address):
    if address in targets:
        targets.remove(address)
    else:
        targets.append(address)

    attack.updateQueue(targets)


# networks currently being disabled
targets = []

# to scan for networks
scanr = scanner.Scanner()

with scanr as scan:
    scan.scanNetworks()

    # to attack networks
    iface = scan.monitor_iface
    attack = attacker.Attacker(iface)
    attack.startAttack()

    # 'graphical' interface setup
    mh = menuHandler()
    mh.load_menus(scan.getNetworks())
    menu = mh.generate_current_menu()
    menu.show()
import attacker
from paConsole import ProixConsole

iface="GUI"

if '-c' in sys.argv:
	iface="Console"

try:
	from PyQt4 import QtGui
	from mainform import *
except:
	print "Unable to load PyQt4 Modules :S"
	iface="Console"

if iface=="GUI":
	app = QtGui.QApplication(sys.argv)
	window = QtGui.QMainWindow()
	ui = Ui_MainWindow()
	ui.setupUi(window)
	
	Proxynet.init("\.(js|jpg|gif|swf|ico|png|bmp|zip|rar|pdf|css|t?gz)$")
	at=attacker.Attacker()
	at.start()
	
	window.show()
	sys.exit(app.exec_())
else:
	pc=ProixConsole()
	pc.run()