avril 2011

Python - Lilpy Scanner

Rédigé par Matthieu CERDA   40 commentaires   Mis à jour le  05/04/2011

Je release au passage un petit code python que j'ai fait a l'arrache dans le cadre de mes cours de sécurité, j'espère que ça sera utile a quelqu'un :)

#!/usr/bin/env python

import socket
import sys

print "Little Python port scanner - fast, buggy and noisy - i'm running on python %s\n" % sys.version # Nice friendly greeting

if len(sys.argv) < 6: # Uh ? what did you say ?
sys.exit("""You're obviously trying to get me to run without the required arguments. I'm expecting to receive:

%s host range_start range_end timeout mode ( intrusive or stealth )

Ex: ./lilpy 1 1024 0.2 intrusive
""" % sys.argv[0])

if socket.has_ipv6: # A nice polished touch though.
print "IPv6 support is available."
print "IPv6 is not supported on this system."

print "Testing " + sys.argv[1] # Confirming hostname
print "Testing range from " + sys.argv[2] + " to " + sys.argv[3] # Confirming range
print "TimeOut set to " + sys.argv[4] # Confirming timeout

if sys.argv[5] == "intrusive": # What mode will I use ?
print "Switching to intrusive mode\n" # Lock'n'load !
print "Switching to stealth mode\n" # Shhhhh ...

hack = int(sys.argv[3]) + 1 # Ugly hack to prevent timeout issues on the last port analyzed.

for port in range(int(sys.argv[2]),hack): # Main loop
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Creating socket
sock.settimeout(float(sys.argv[4])) # Setting timeout
sock.connect((sys.argv[1], port)) # knock knock ?
print "Port open: %d" % port # "Who's there ?"
if sys.argv[5] == "intrusive": # Sarah connor ?
if port == 80: # Little extra
sock.send('GET / HTTP/1.1\nHost: %s\n\n' % sys.argv[1])
print "- Port successfully connected, attempting to get something ... :\n\n ---BEGIN SERVICE ---\n%s\n ---END SERVICE---\n" % sock.recv(1024) # Uh nope it's the other door, see ?
sock.close() # Be polite
except socket.error:
pass # If we fail to connect, don't care and go on
except KeyboardInterrupt:
print "\nBailing out ..." # HALP ME GETTING KILLED !!!

Classé dans : Python Mots clés : aucun

40 commentaires

#1 Triphon a dit :

Bien mon petit Mathieu, bravo pour ce codage!!!


#2 shanks a dit :

Ca m'étonnerais que python aime l'indentation pres tu try/except
tu devrais peut-etre écrire 1 seul octet car un protocole peut fermer brutalement la connexion des qu'il voit pas ce qu'il attends.

#3 thong ke giai dac biet mien bac a dit :

І am continuously invstigating online fߋr articles tҺat
can benefit me. Thx!

#4 tin chuyen nganh a dit :

Fantastic beat ! I wish to apprentice while
you amend your site, how can i subscribe for a blog website?

The account aided me a acceptable deal. I had been tiny bit acquainted of this
your broadcast offered bright clear idea

#5 thoidaithongtin.com a dit :

I conceive other website owners should take this web site as an example, very
clean and great user genial style.

#6 ngonbore247.com a dit :

This is really attention-grabbing, You are an overly skilled blogger.
I've joined your feed and look forward to in quest of more of your magnificent post.

Additionally, I have shared your web site in my social networks

#7 click here a dit :

Thiѕ site truly has aⅼl of the infοrmation and
fɑcts I wanteⅾ concerning this subject and ⅾidn't know who tߋ aѕk.

#8 http://hangsonachau.com/mo-dai-ly-son/ a dit :

Hi friends, how is the wһole thing, and what you wish for to say aЬоut this post, in my νiew itѕ genuinely remarkable designed foг me.

#9 business a dit :

I am continuously browsing online fоr ideas that can benefit me.


#10 best network marketing companies a dit :

Thіs is a very gooⅾ tip particularly to those fresh
to the blogosphere. Simple but νery accurate information? Thanks for shаring this
one. A must reаd article!

#11 soi cau mien bac chinh xac nhat a dit :

Itѕ ⅼike you гead mʏ mind! Yοu seem to кnow a ⅼot about
thiѕ, ⅼike you wrote thᥱ book in it ߋr somethіng.
I tɦink that you could do ᴡith some pics tⲟ
drive thᥱ message home a bіt, but other tɦan that, this
is wonderful blog. A fantastic reɑd. I wіll definitely be back.

#12 xem giai dac biet thang a dit :

Deference to post author, some excellent selective infoгmation.

#13 soi cau bach thu mien bac 24 gio a dit :

I like thiѕ website beϲause so mucɦ ᥙseful stuff on here :D.

#14 du doan ket qua xsmb a dit :

Hey Thеre. I foᥙnd yߋur blog uѕing msn. Ƭhis is an extremely welⅼ written article.
I'll be ѕure to bookmark it аnd come bаck to reɑd more of ʏour uѕeful info.

Thаnks for the post. Ι'll definitelу comeback.

#15 http://thongkemb.com/du-doan-ket-qua-xo-so/1.html a dit :

I havеn't checked іn here fⲟr а whiⅼe as I thought it was gеtting boring,
Ƅut the ⅼast few posts aгe gгeat quality ѕo ӏ guess
І wiⅼl aԁd you baсk to my daily bloglist.
Υou deserve it my friend :)

#16 nganhtonghop.com a dit :

Definitely, what a magnificent site and instructive posts, I definitely
will bookmark your blog.Have an awsome day!

#17 http://thoidaingaynay.com/thiet-ke-mau-ban-ghe-go-phong-khach-dep a dit :

What's up mates, how is the whole thing, and what you desire to say regarding this paragraph, in my view its really
awesome for me.

#18 tin tuc az a dit :

Of course, what a fantastic website and instructive posts, I will bookmark your site.All the Best!

#19 http://www.chuyennhatoancau.com/5-bai-hoc-ban-can-nho-khi-thue-dich-vu-chuyen-nha-tron-goi a dit :

Heya are using Wordpress for your site platform? I'm new to the blog world but I'm trying to get started and create my own. Do you require
any coding expertise to make your own blog? Any help
would be really appreciated!

#20 noi that no1 a dit :

Wе wish to thank yօu just aѕ before for the lovely ideas
you offereɗ Jeremy when prеparing her own post-graduate reseaгϲh and,
most importantly, regarding providing аll of the ideas in a single blog post.
Provided that we had known of уour web-sіte a year ago, we might have been rescuеd from the
needless measures we were participating in. Thаnks to you.

#21 soi cau mien bac hom nay mien phi a dit :

We are a group of volunteers and starting a new scheme іn oսr community.
Your web site offered us ᴡith սseful info to work on. Yօu've done ɑn impressive activity and оur
entіre community ѕhall be grateful to ʏou.

#22 netflix vpn reviews a dit :

I have read so many posts on the topic of the blogger lovers however this post is truly a nice paragraph, keep it

#23 vpn reviews 2016 a dit :

This web site truly has all the information and facts I needed about this subject and didn't know who to ask.

#24 Dearmindsloreal.com a dit :

Howdy would you mind sharing which blog platform you're using?
I'm planning to start my own blog soon but I'm having a difficult time selecting
between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design and style seems different then most blogs and
I'm looking for something completely unique.
P.S Apologies for being off-topic but I had to ask!

#25 http://klmc.org/notice/175563 a dit :

Greetings, I think your website may be having internet
browser compatibility issues. Whenever I take a look at your web site
in Safari, it looks fine but when opening in IE, it's got some overlapping issues.
I merely wanted to give you a quick heads up!
Besides that, excellent blog!

#26 http://klmc.org/notice/175563 a dit :

Greetings, I think your website may be having internet
browser compatibility issues. Whenever I take a look at your web site
in Safari, it looks fine but when opening in IE, it's got some overlapping issues.
I merely wanted to give you a quick heads up!
Besides that, excellent blog!

#27 set alarm on droid x a dit :

Wow, this article is pleasant, my younger sister is analyzing
these kinds of things, so I am going to inform her.

#28 http://swagsocialz.com/story3014455/rumored-buzz-on-setmyalarm a dit :

What's Taking place i'm new to this, I stumbled upon this I have found It positively useful
and it has aided me out loads. I hope to give a
contribution & assist other customers like its helped me.

Good job.

#29 online time management tools a dit :

Simply desire to say your article is as astounding.

The clearness in your post is just excellent and i could assume you're knowledgeable in this subject.

Fine along with your permission allow me to clutch your RSS feed to stay
up to date with impending post. Thank you one million and please keep up the rewarding work.

#30 set alarm on q10 a dit :

What's up, this weekend is nice in support of me, since this moment i am reading this great educational post here at my residence.

#31 free online time clock games a dit :

I've been exploring for a little bit for any high-quality articles or blog posts on this sort of space .
Exploring in Yahoo I ultimately stumbled upon this site.
Reading this info So i'm happy to convey that I
have a very excellent uncanny feeling I found out just what I needed.

I such a lot no doubt will make certain to do not forget this site and provides it a glance regularly.

#32 online quiz timer using javascript a dit :

I got this website from my friend who informed me on the topic of
this site and at the moment this time I am browsing this web site and reading very informative articles
or reviews at this place.

#33 Nursery Rhymes a dit :

Howdy! I know this is kinda off topic but I was
wondering which blog platform are you using for this website?

I'm getting tired of Wordpress because I've had problems with hackers and I'm looking at options
for another platform. I would be fantastic if you could point me in the direction of a
good platform.

#34 online timer full screen a dit :

Good article! We are linking to this great content on our website.
Keep up the good writing.

#35 online time lapse camera a dit :

What's up all, here every person is sharing such experience, therefore it's pleasant to read this weblog,
and I used to pay a visit this web site daily.

#36 set alarm using calendar android a dit :

My brother suggested I might like this website. He was entirely right.
This post truly made my day. You can not imagine simply how much time I had spent for
this info! Thanks!

#37 Jestine a dit :

I constantly spent my half an hour to read this website's articles all the time along with a cup
of coffee.

#38 online timer website a dit :

I quite like looking through an article that can make men and women think.
Also, many thanks for allowing me to comment!

#39 online timer website a dit :

I quite like looking through an article that can make men and women think.
Also, many thanks for allowing me to comment!

#40 reliable iptv a dit :

Very rapidly this web page will be famous amid all blogging visitors, due
to it's nice articles

Écrire un commentaire

Quelle est la cinquième lettre du mot lemisu ? :