i know its a dumb question. but belive me - i searched i all the internet and i didnt got any answer.
first of all, there is my code:
def Make_Get():
synR = IP(dst = 'www.google.com', ttl = 64)/TCP(dport = 80, flags = 'S')
synAckAN = sr1(synR)
getStr = 'GET /index.html HTTP/1.0 \n\n'
req = (IP(dst = 'www.google.com', ttl = 64)/TCP(dport = 80, sport = synAckAN[TCP].dport, seq = synAckAN[TCP].ack, ack = synAckAN[TCP].seq+1, flags = 'A')/getStr)
ans, unans = sr(req)
return ans, unans
when i run this function and tring to print the "ans" (first parameter) - its giving me an answer without the data.
look:
Received 1 packets, got 1 answers, remaining 0 packets
###[ IP ]###
version = 4L
ihl = 5L
tos = 0x0
len = 40
id = 9784
flags =
frag = 0L
ttl = 128
proto = tcp
chksum = 0xc02f
src = 216.58.210.4
dst = 192.168.233.128
\options \
###[ TCP ]###
sport = http
dport = ftp_data
seq = 2116250139
ack = 28
dataofs = 5L
reserved = 0L
flags = A
window = 64240
chksum = 0x77bc
urgptr = 0
options = {}
###[ Padding ]###
load = '\x00\x00\x00\x00\x00\x00'
None
there is no any data.......
but when i sniffed the transmition in Wireshark, i'd got an html code in a packet.
my question is - how can i send a Get request like i did, and save the html code from the site (to print it, or to a file.. doesnt metter..)
I'd highly recommend using scapy-http, which is a scapy extension that helps you support HTTP.
Related
I have some problem. If I have old firmware (NodeMCU 0.9.5 build 20150318 powered by Lua 5.1.4) then it works and I receive back response to phone. But if I have new one ( build 2022-09-07 powered by Lua 5.1.4 on SDK 3.0.1-dev(fce080e)) then I do not receive response (but I get request “who” on ESP8266). What is the problem it could be?
Code:
srv = net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive", function(client,request)
local buf = "";
buf = buf.."HTTP/1.1 200 OK\n\n"
local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP");
if(method == nil)then
_, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP");
end
local _GET = {}
if (vars ~= nil)then
for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
_GET[k] = v
end
end
if(_GET.pin == "ON1")then
print(“On”)
elseif(_GET.pin == "OFF1") then
print(“Off”)
end
if(_GET.question == "who") then
buf=""
buf = buf.."HTTP/1.1 200 OK\n\n"
print(buf)
end
client:send(buf)
client:close()
collectgarbage()
end)
end)
I'm struggling in using Python3 for writing and reading personal user id in rc522. Here I want to write (for example, 123) in the rfid based on the input. However, after I write '123', the python says
can't concat list to bytearray.
Please, help. Thank you :D
info = input("Personal ID")
info = int(info)
status = MIFAREReader.MFRC522_Auth(MIFAREReader.PICC_AUTHENT1A,8,key,uid)
if status == MIFAREReader.MI_OK:
data = bytearray(16)
value = format(info,'x')
while (8 > len(value)):
value = '0' + value
data[0:8] = bytearray.fromhex(value)
MIFAREReader.MFRC522_Write(8,data)
def (self,blockAddr,writeData)
buff = []
buff.append(self.PICC_WRITE)
buff.append(blockAddr)
crc = self.CalulateCRC(buff)
buff += crc
(status,backData,backLen) = self.MFRC522_ToCard(
self.PCD_TRANSCEIVE,buff
)
buff = writeData[0:8]
crc = self.CalulateCRC(buff)
buff += crc /////the error is pointed here
(status,backData,backLen) = self.MFRC522_ToCard(
self.PCD_TRANSCEIVE,buff
)
if status == self.MI_OK:
return True
I did Server-Client Application with lua using one Esp8266. I wanna do this with two Esp8266. I wanna use one of these Esp8266 is Server and the other other one is Client. You can see below first code using for get RSSI from one AP and second code is using for writing these RSSI in a Server. How can i placed these two codes in two Esp8266?
i=5
tmr.alarm(1,10000,1, function()
print(wifi.sta.getap(scan_cfg, 1, listap))
if i>1 then
print(i)
i=i-1
else
tmr.stop(1)
print("Timer Durdu")
end
end
)
function listap(t)
for bssid,v in pairs(t) do
local ssid = string.match(v, "([^,]+)")
l=string.format("%-10s",ssid)
stringtoarray = {}
index = 1
for value in string.gmatch(v,"%w+") do
stringtoarray [index] = value
index = index + 1
end
print(l)
print(stringtoarray[2])
end
end
scan_cfg = {}
scan_cfg.ssid = "VSP250s"
scan_cfg.bssid = "00:09:df:8e:03:b4"
scan_cfg.channel = 0
scan_cfg.show_hidden = 1
Second code:
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive", function(client,request)
local buf = "";
local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP");
if(method == nil)then
_, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP");
end
local _GET = {}
if (vars ~= nil)then
for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
_GET[k] = v
end
end
buf = buf.."<!DOCTYPE html><html><div id='container'><font size='5'>"
buf = buf..'<style>body{width:auto;height:auto;background-color:#ffffff;}'
buf = buf..'.button {font-size: 20px;}</style>'
buf = buf.."<head> <meta http-equiv='refresh' content=3> "
buf = buf.."<p><h1>RSSI meter<br> ESP8266</h1>";
--buf = buf.."<p>Refresh : <button class='button'>ON</button> </p>";
--buf = buf.."<p>Relay Switch : <button class='button'>ON</button> "
--buf = buf.."<button class='button'>OFF</button><br>"
buf = buf..'<B>Voltage :<font color=red>'..string.format('%s',l)..' V</font></b><br>'
buf = buf..'<B>Current :<B><font color=blue>'..string.format('%g',stringtoarray[2])..' A</font></b><br>'
--buf = buf..'<B>Power Consumption :<B><font color=DeepSkyBlue>'..'Not Available'..'</font></b><br><BR>'
-- buf = buf..'<p>Function Button :<B><font color=BlueViolet>'..button_status..'</font></b><br></p>';
buf = buf..'</head>'
buf = buf..'<br><br><details><summary><font color=red>BURAK IPEK</font><p>'
buf = buf..'<summary><p>Vestel Electronics </p></details>'
buf = buf.."</body></font></div></html>"
client:send(buf);
client:close();
collectgarbage();
end)
end)
Put each code into a lua file. Include both from init.lua with typing
dofile("client.lua");
dofile("server.lua");
To make things easier, write methods.
Good luck.
I use scapy to intercept DNS request and forge a response. The interception and forging parts work fine, and it seems that the sending of the forged packet works (at least I can see the dot indicating the success of the sendp function). But, on the target station I don't receive the packet -- or I don't see it on Wireshark.
I don't know where my problem is, but I guess it is not in the DNS/UDP part (the packet would be visible in Wireshark). So it's probably in the 802.11 or IP layers.
Here is a request:
192.168.2.117 (a4:4e:31:5c:54:78) -> 194.2.0.50 (00:14:d1:ad:9f:88)
DNS request for www.youtube.com.
###[ RadioTap dummy ]###
version = 0
pad = 0
len = 38
present = TSFT+Flags+Rate+Channel+dBm_AntSignal+b14+b29+Ext
notdecoded= ' \x08\x00\xa0 \x08\x00\x00\xc8+\xa3\x10\x00\x00\x00\x00\x10l\x9e\t\xc0\x00\xd5\x00\x00\x00\xcd\x00\xd4\x01'
###[ 802.11 ]###
subtype = 8L
type = Data
proto = 0L
FCfield = to-DS
ID = 11264
addr1 = 00:14:d1:ad:9f:88
addr2 = a4:4e:31:5c:54:78
addr3 = 00:25:9c:9a:aa:b1
SC = 4272
addr4 = None
###[ 802.11 QoS ]###
TID = 0L
EOSP = 0L
Ack Policy= 0L
Reserved = 0L
TXOP = 0
###[ LLC ]###
dsap = 0xaa
ssap = 0xaa
ctrl = 3
###[ SNAP ]###
OUI = 0x0
code = 0x800
###[ IP ]###
version = 4L
ihl = 5L
tos = 0x0
len = 61
id = 213
flags =
frag = 0L
ttl = 128
proto = udp
chksum = 0xb489
src = 192.168.2.117
dst = 194.2.0.50
\options \
###[ UDP ]###
sport = 50648
dport = domain
len = 41
chksum = 0x7b3c
###[ DNS ]###
id = 64118
qr = 0L
opcode = QUERY
aa = 0L
tc = 0L
rd = 1L
ra = 0L
z = 0L
rcode = ok
qdcount = 1
ancount = 0
nscount = 0
arcount = 0
\qd \
|###[ DNS Question Record ]###
| qname = 'www.youtube.com.'
| qtype = A
| qclass = IN
an = None
ns = None
ar = None
###[ Padding ]###
load = '\xb2\x17\xa3\x8a'
And the forged response:
###[ RadioTap dummy ]###
version = 0
pad = 0
len = 38
present = TSFT+Flags+Rate+Channel+dBm_AntSignal+b14+b29+Ext
notdecoded= ' \x08\x00\xa0 \x08\x00\x00\xc8+\xa3\x10\x00\x00\x00\x00\x10l\x9e\t\xc0\x00\xd5\x00\x00\x00\xcd\x00\xd4\x01'
###[ 802.11 ]###
subtype = 8L
type = Data
proto = 0L
FCfield = from-DS
ID = 11264
addr1 = a4:4e:31:5c:54:78
addr2 = 00:14:d1:ad:9f:88
addr3 = 00:25:9c:9a:aa:b1
SC = 14272
addr4 = None
###[ 802.11 QoS ]###
TID = 0L
EOSP = 0L
Ack Policy= 0L
Reserved = 0L
TXOP = 0
###[ LLC ]###
dsap = 0xaa
ssap = 0xaa
ctrl = 3
###[ SNAP ]###
OUI = 0x0
code = 0x800
###[ IP ]###
version = 4L
ihl = 5L
tos = 0x0
len = None
id = 213
flags =
frag = 0L
ttl = 128
proto = udp
chksum = None
src = 194.2.0.50
dst = 192.168.2.117
\options \
###[ UDP ]###
sport = domain
dport = 50648
len = None
chksum = None
###[ DNS ]###
id = 64118
qr = 1L
opcode = QUERY
aa = 0L
tc = 0L
rd = 1L
ra = 1L
z = 0L
rcode = ok
qdcount = 1
ancount = 1
nscount = 0
arcount = 0
\qd \
|###[ DNS Question Record ]###
| qname = 'www.youtube.com.'
| qtype = A
| qclass = IN
\an \
|###[ DNS Resource Record ]###
| rrname = 'www.youtube.com.'
| type = A
| rclass = IN
| ttl = 900
| rdlen = 4
| rdata = '192.168.2.100'
ns = None
ar = None
###[ Padding ]###
load = '\xb2\x17\xa3\x8a'
I tried to check with a valid DNS response, I don't see any difference explaining my problem. I tried to modify the ID and SC fields, but it doesn't change anything. The addr3 doesn't change.
Do you see an error explaining why the target doesn't receive it?
Well, the length of your IP response is 'None'. That would not go well in processing. :) That's the obvious thing that stands out. Also, your overall length at the top doesn't change, even though you've added data.
I'm not sure what sport/dport = domain means; I'm assuming those are port 53.
The IP ID fields should be generally be different in the query/response, but that wouldn't impact your results here.
I'm sending POST request using URLLoader and URLRequest with XML data. Then API sends response with redirect page(Location header) and i want to get this URL. How do I catch this response?
UPD:
Event.COMPLETE in debugger:
event = flash.events.Event (#6e1edf9)
bubbles = false
cancelable = false
currentTarget = flash.net.URLLoader (#418e241)
[inherited] =
bytesLoaded = 1
bytesTotal = 0
data = " "
dataFormat = "text"
stream = flash.net.URLStream (#77c5fb9)
[inherited] =
bytesAvailable = 0
connected = true
endian = "bigEndian"
objectEncoding = 3
eventPhase = 2
target = flash.net.URLLoader (#418e241)
[inherited] =
bytesLoaded = 1
bytesTotal = 0
data = " "
dataFormat = "text"
stream = flash.net.URLStream (#77c5fb9)
type = "complete"
Listen on the httpResponseStatus event of the URLLoader. The event details contains a property called responseHeaders that can provide you with location header. See http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html#event:httpResponseStatus for details.
Also, to prevent redirect you can set followRedirects on URLRequest to false. See http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLRequest.html#followRedirects for details.