Crafting a DHCP OFFER packet in scapy
I'm writing a very simple DHCP server using scapy and I'm stuck on sending an offer packet. Right now I'm doing it like this:
ethernet=Ether(dst=dest_mac, src=hw, type=0x800) ip=IP(dst=dest_addr, src=srv_ip) udp=UDP(sport=67, dport=68) bootp=BOOTP(op=2, yiaddr=dest_addr, siaddr=srv_ip, chaddr=client_mac) dhcp=DHCP(options=[("message-type", "offer"), ("server_id", dest_addr), ("broadcast_address", broadcast), ("router", gateway), ("subnet_mask", netmask)]) of_pack=ethernet/ip/udp/bootp/dhcp sendp(of_pack)
Client is ISC DHCP, installed on ubuntu server 16.04. I can see Discovery packets sent by dhclient in Wireshark, but I can't see offer packets which are sent by my server (scapy says: sent 1 packets, so it looks ok). So I think I've done something wrong while crafting the offer packet.
As it doesn't even can be seen in Wireshark, I think the problem somewhere is on IP protocol layer or lower (I sent malformed packets earlier and I could see them in Wireshark).
Not sure, but maybe problem is in checksums and/or length of IP header? Should I calculate it manually or scapy can do it itself?
I added interface name to sendp: sendp(of_pack, iface="ens33"). Now it at least can be seen through wireshark.
See also questions close to this topic
Keras Lambda Layer Before Embedding: Use to Convert Text to Integers
I currently have a
kerasmodel which uses an
Embeddinglayer. Something like this:
input = tf.keras.layers.Input(shape=(20,) dtype='int32') x = tf.keras.layers.Embedding(input_dim=1000, output_dim=50, input_length=20, trainable=True, embeddings_initializer='glorot_uniform', mask_zero=False)(input)
This is great and works as expected. However, I want to be able to send text to my model, have it preprocess the text into integers, and continue normally.
1) The Keras docs say that Embedding layers can only be used as the first layer in a model: https://keras.io/layers/embeddings/
2) Even if I could add a
Lambdalayer before the
Embedding, I'd need it to keep track of certain state (like a dictionary mapping specific words to integers). How might I go about this stateful preprocessing?
In short, I need to modify the underlying Tensorflow DAG, so when I save my model and upload to ML Engine, it'll be able to handle my sending it raw text.
PySpark: Sort or OrderBy DataFrame Column *Numerically* not working correctly
I have some fitness data that I'm trying to sort numerically, however the results are not turning out as the manual, and other examples, e.g. Spark DataFrame groupBy and sort in the descending order (pyspark), show:
display(df.sort(col("Calories Burned").desc()))#fails to sort correctly, shows 876, then 4756, display(df.orderBy("Calories Burned", ascending = False))#fails to sort correctly, shows 876, then 4756 display(df.sort(desc("Calories Burned")))
All these examples display the following two columns data (there are more columns, but I'm abbreviating for space):
Date Calories Burned 2018-10-18 876 2018-05-26 4756 2018-05-05 4440
As you can see, these are not sorting numerically. Spark isn't taking the number of digits into account, so 876 appears before 4756.
Whether or not I include the
colfunction makes no difference, either.
How can this dataset be sorted numerically so the data looks more like this?
Date Calories Burned 2018-05-26 4756 2018-05-05 4440 2018-10-18 876
Turtle is not reacting to onkeypress [SOLVED]
So, I am new in python so I took some time and watched some videos about how to make a simple "snake" game, I was doing everything that dude was saying, but when it came to the keyboard binding something went wrong and I can't move my turtle..
import turtle import time delay = 0.1 # Screen wn = turtle.Screen() wn.title("Snake Game By AniPita") wn.bgcolor('black') wn.setup(600, 600) wn.tracer(0) # Snake Head head = turtle.Turtle() head.speed(0) head.shape("square") head.color("white") head.penup() head.goto(0, 0) head.direction = "stop" # Functions def go_up(): head.direction == "up" def go_down(): head.direction == "down" def go_left(): head.direction == "left" def go_right(): head.direction == "right" def move(): if head.direction == "up": y = head.ycor() head.sety(y + 10) if head.direction == "down": y = head.ycor() head.sety(y - 10) if head.direction == "left": x = head.xcor() head.setx(x - 10) if head.direction == "right": x = head.xcor() head.setx(x + 10) # Keyboard Bindings wn.onkeypress(go_up(), 'w') wn.onkeypress(go_down(), 's') wn.onkeypress(go_left(), 'a') wn.onkeypress(go_right(), 'd') wn.listen() # Main Game while True: wn.update() time.sleep(delay) move() wn.mainloop()
Wireless Connection Location
I am developing emergency notification system and running windows service to check active alerts based on logged-in user's location however when user connects with wireless then i do not know the location because I use centralized network and only wired connections have IP range but no IP range for access points. I have over 50 buildings and some of them so close to each other they may overlap wireless connections.
How to know user's building if h/she use wireless connection? or what else can i try to overcome this?
How to see devices ip in child TP-Link Routers from Main Modem?
Actually i wanna see all devices connected in Child Modems... Details:
1.) I have a Modem with ip-address/Default-Gateway 192.168.10.1, i have ip address of 192.168.10.4(My Laptop's ip)
2.) A tp-link1 router connected on ip address 192.168.10.2 with its own gateway of 192.168.10.1, subnet 255.255.255.0 and ip range 192.168.0.100-199
3.) Another tp-link2 router connected on ip address 192.168.10.3 with its own gateway of 192.168.10.1, subnet 255.255.255.0 and ip range 192.168.0.100-199
Now i wanna see list of devices with nmap or any tool connected with tplink1 and tplink2...
i disabled firewall on both tplink routers but it doesn't helped... and modem doesn't have any firewall i guess... Any help will be much appreciated...
Can only send emails when using IP of SMTP host
I have this annoying issue:
- When sending an email when debugging in VS, it works fine (I'm using
After publishing to the server, I get this error:
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: The remote name could not be resolved: 'mail.company.co.za'
However, if I change the smtp host to the IP address, it seems to work fine.
I got the IP by calling
ping mail.company.co.zain CMD (When calling this on the server it can't find the address, but it can ping the IP)
Since I'm not sure whether the IP is static or not, I don't know if its safe to just use the physical IP. Why would the server not recognise the
Note that I am debugging and hosting the application on the same network. This suggests to me that it is not a firewall issue, but maybe I'm wrong about that?
- When sending an email when debugging in VS, it works fine (I'm using
Is it possible to modify simple ICMP to ask for other information?
First sorry for typo. So basically I understood that ICMP is a simple "hey , are you alive?" Check. And if so please send X. Is it possible to modify ICMP to ask for other data ?
"If your alive please send me your device name".
Is it possible ? I'm planing trying build it in python using scapy :)
unable to receive the answer of a fragmented ICMP Echo Request
I am trying to send manually a big ICMP Echo Request, therefore I wrote following scapy code:
frags = fragment(IP(dst=dst)/ICMP()/Raw(load=('x')*50000)) s = conf.L3socket(iface=iface) #improve Sending performance (https://byt3bl33d3r.github.io/mad-max-scapy-improving-scapys-packet-sending-performance.html) count = len(frags) #Count fragments i = 0 maximum = count - 1 print "maximum: " + str(maximum) #Send all Frags but the last while i < maximum: print "i: " + str(i) s.send(frags[i]) i = i + 1 answer = s.sr(frags[i]) # using sr(), to receive an answer print(ans)
It doesn't work to receive an ICMP Echo response. The Answer I get is always something like
Received 9 packets, got 0 answers, remaining 1 packets
Does someone know, what's wrong with my code?
Why I cant see attacker's adress in dns path
I'm trying to make a DNS-tracer in order to trace the path a dns request takes to destination to make sure it is not being redirected or hijacked. Using the
dnstraceroutetool, everything works fine and i can detect a demo dns spoofing attacks that I've ran. I wrote this code using scapy in order to do the same:
from scapy.all import * import time for i in range(1, 28): pkt = IP(dst='220.127.116.11', ttl=i) / UDP(sport=RandShort(),dport=53)/DNS(id = 102, qd=DNSQR(qname="www.google.com")) # Send the packet and get a reply reply = sr1(pkt, verbose=0) if reply is None: # No reply =( print(i+ " ======[-]=====") elif reply.type == 3: # Destination Unreachable Message print ("Done!", reply.src) break else: # We're somewhere in the middle print ("%d hops away: " % i , reply.src) time.sleep(1)
It works fine and I can see the path as expected. But, when i'm redirecting the dns queries to my attacker machine, I cant detect the redirection. The original dns server in my network responses to the first dns packet(where ttl value is 1) with a ICMP packet, even thought the attacker machine received the packet before. But again, Using the
dnstraceroutetool, the attacker machine responses to this packet and I can see it's adress in the output.
I opened wireshark and tried to look for something different between the packets, But they're allmost the same .Here is the DNS packet which generated by my script, and Here is the Dns packet which sent by
I cant figure out what makes the difference. Thanks in advance!
How to fetch ISP internet connection type using python?
My program has a requirement to dynamically adjust some parameters based on the internet connection type provided by the ISP.
For instance if the connection type is DHCP, my program will behave slightly differently and if it is PPPoE, it will behave otherwise.
But is there a way to fetch these details using Python?
A quick google search brings up ways to fetch details like public IP, hostname, etc. But no mention of connection type anywhere.
Any help is appreciated. Thanks! :)
PowerDNS Master Slave Configuration
I deployed 4 powerDNS instances. 2 in NJ (nj-ns1 and nj-ns2) and 2 others in LA (la-ns1 and la-ns2).
Configured pdns in pdns.conf as, nj-ns1 as master. nj-ns2 la-ns1 and la-ns2 as Slaves.
Each of the NS also run DHCP. The 2 NS in NJ only manage NJ host and 2 NS in LA only mange LA hosts. I configured DHCP to update DNS with the leases.
My question is, If I create a dns zone (called la.test) with la-ns1 as master ns, would dhcp in LA be able to add A records to it? even though it is not a "powerDNS master"? I am basically confused about the difference between setting Master in pdns.conf vs. on the zone itself.
Issue setting up Open vSwitch on GCE (DHCP client not working)
I am trying to simulate an on-premises solution on GCP. I am not able to bridge with the GCE NIC and get DHCP working on that.
I have isolated the issue and also successfully tests the similar thing on a sandboxed Vagrant (VirtualBox) setup.
Both approaches are scripted and available on the following repos: https://github.com/htssouza/ovs-gcp-issue