Send and receive packet to and from nodes using pycore library in python script -
#!/usr/bin/python core import pycore import logging logging.getlogger("scapy.runtime").setlevel(logging.error) scapy.all import * session = pycore.session(persistent=true) node1 = session.addobj(cls=pycore.nodes.corenode, name="node1") node2 = session.addobj(cls=pycore.nodes.corenode, name="node2") hub1 = session.addobj(cls=pycore.nodes.hubnode, name="hub") node1.newnetif(hub1, ["10.0.0.1/24"]) node2.newnetif(hub1, ["10.0.0.2/24"]) packet = ip(src="10.0.0.1",dst="10.0.0.2")/icmp()/"hello world"
here have created 2 nodes i.e node1
, node2
connected hub named hub1
. node2
pingable node1
want send packet (i made in last line of code) node1
node2
, process packet after receiving @ node2
. kindly me out!
to send file on network can use netcat on linux. , in core, can send shell commands these nodes. hence can following.
node1.shcmd("nc -l 4444 > download.txt") node2.shcmd("nc -w3 10.0.0.1 4444 < upload.txt")
the file upload.txt assumed present on virtual node, node2, , copied on virtual node node1 under file name download.txt
to create file, can again use shcmd pass shell command create file.
node2.shcmd("dd if=/dev/urandom of=upload.txt bs=1024 count=100")
this create 102kb file on node2. make sure use command before use netcat.
Comments
Post a Comment