Closed loveshell closed 10 years ago
This code works only on haka v0.1
Hereafter, a slightly modified version that works on haka v0.2:
raw = require('protocol/raw')
ipv4 = require('protocol/ipv4')
tcp = require('protocol/tcp')
haka.rule {
hook = tcp.events.receive_packet,
eval = function(pkt)
local flags = pkt.flags.all
-- test for null, fin and xmas nmap scans
if flags == 0 or flags == 0x1 or flags == 0x29 then
-- raw packet
local rstpkt = raw.create()
-- ip packet
rstpkt = ipv4.create(rstpkt)
rstpkt.ttl = pkt.ip.ttl
rstpkt.dst = pkt.ip.src
rstpkt.src = pkt.ip.dst
-- tcp packet
rstpkt = tcp.create(rstpkt)
rstpkt.srcport = pkt.dstport
rstpkt.dstport = pkt.srcport
rstpkt.flags.rst = true
rstpkt.flags.ack = true
rstpkt.ack_seq = pkt.seq + 1
-- inject forged packet and
-- drop malicious scanning packet
rstpkt:send()
pkt:drop()
end
end
}
We will update the blog post on haka-security.org as soon as possible.
The blog post has been updated: http://www.haka-security.org/blog/2014/04/10/defeating-nmap-scans.html.
i test this http://www.haka-security.org/blog/2014/04/10/defeating-nmap-scans.html,and happend problem