コード例 #1
0
from umit.umpa.protocols import IP, TCP, Payload

# NOTE:
# to create RAW_SOCKET we need SUID, but for normal usage it's not
# necessary. we recommend to use umit.umpa.utils.security to make our programs
# more safety. also dropping priviliges should be done at the same beginning
# of the application

# dropping unnecessary priviliges
umit.umpa.utils.security.drop_priviliges()

# create new IP object
ip = IP()
# setting some fields
ip.src = "127.0.0.1"
ip.dst = "67.205.14.183"

# the same for TCP
tcp = TCP()
# setting some fields
tcp.srcport = 2958
tcp.dstport = 0

# also, SYN flag will be set up. here SYN
tcp.set_flags('flags', syn=True)

# create payload object and set the data while calling constructor
payload = Payload(data="something here")

# create a new packet and include one protocol (ip)
packet = umit.umpa.Packet(ip)
コード例 #2
0
ファイル: udp.py プロジェクト: umitproject/umpa
from umit.umpa.protocols import IP, UDP

# NOTE:
# to create RAW_SOCKET we need SUID, but for normal usage it's not
# necessary. we recommend to use umit.umpa.utils.security to make our programs
# more safety. also dropping priviliges should be done at the same beginning
# of the application

# dropping unnecessary priviliges
umit.umpa.utils.security.drop_priviliges()

# create new IP object
ip = IP()
# setting some fields
ip.src = "127.0.0.1"
ip.dst = "67.205.14.183"

# create new UDP object
udp = UDP()
# setting some fields
udp.srcport = 0
udp.dstport = 7

# create a new packet and include protocols
packet = umit.umpa.Packet(ip, udp)

# creating new socket connection
# NOTE: we need to raise our priviliges.
# we can call super_priviliges() function and pass function which need these
# priviliges as an argument. after that, we drop priviliges automatically