Spam catcher (was Re: Separating IP nodes)
hzhu at yahoo.com
Wed Sep 6 02:30:30 CEST 2000
On Sun, 03 Sep 2000 23:22:41 -0600, Kevin Breit
<battery841 at remove.for.no.spam.mypad.com> wrote:
> In my app, I have a user enter an IP address. Great. Now, I want to
>increment the last number. For example:
>126.96.36.199 becomes 188.8.131.52 (yes...thats an odd IP)
>What is the best way to separate that and increment only the last number?
>I'm thinking some sort of regex, but not sure.
This is not what you are looking for, but it's related, and I thought it
might be useful to others: As I've had received quite a few spams recently
I've written this little program so that I can catch the host of the spammer
and report to their ISP.
$Id: ip_demangle.py,v 184.108.40.206 2000/09/06 00:30:46 hzhu Exp $
ip_demangle.py: Demangle an ip address written as a single number
Useful for catching spammers hiding behind little tricks.
Use it like:
python ip_demangle.py 00032100360014
def ip_demangler(ip, show_intermediate=0):
hexcode = hex(ip)
ip4 = 
if show_intermediate: print "hex dec"
for i in range(4):
hseg = hexcode[(i+1)*2 : (i+2)*2]
dseg = str(eval('0x'+hseg))
if show_intermediate: print " %s % 3s" %(hseg, dseg)
if __name__ == "__main__":
import sys, os
ips = sys.argv[1:] or ["3627528556"]
for ip in ips:
print "original", ip
ip = eval(ip+"L")
print "decimal:", ip
ip = ip_demangler(ip, 1)
print "conventional:", ip
os.system("nslookup " + ip)
More information about the Python-list