Devilzc0de Forum Follow @devilzc0de
  • Home
  • Hacking
  • Networking
  • Programming
  • O.S
  • Server
  • Tweets
  • Search
  • Member List
  • Calendar
Current time: 05-18-2013, 08:22 PM Hello There, Guest! (Login — Register)
Devilzc0de Forum › Information Technology › Programming › Python v
« Previous 1 2 3 4

Simple Network Intrussion Detection System with .py

Home General Computer Multimedia Business Lounge

Post Reply 
Tweet
Threaded Mode | Linear Mode
Simple Network Intrussion Detection System with .py
11-17-2010, 09:07 AM (This post was last modified: 11-17-2010 09:08 AM by 5ynL0rd.)
Post: #1
5ynL0rd Offline
DC Senior
***
Posts: 53
Joined: Oct 2010
Reputation: 14
Simple Network Intrussion Detection System with .py
i'll give sample code (snippets) for capture the bad content in ur network (if u put & run this script in router). this script would be give us alert message and log the IP if network packet have been specified content (example: sex content) and u could be add function for prevention with iptables. U can contact me if u want to develop to Network Intrussion Prevention System

Simple IDS (No Prevention):
Code:
#!/usr/bin/python
# simple Network Intrussion Detection System using
# pcapy module (please running this script example
# with sudo/root because raw socket must be root
# priviledge
#
# Scripter: 5ynL0rd
#
# download pcapy in ur Ubuntu:
# $ sudo apt-get install python-pcapy
# or (if u have pip)
# $ sudo pip install pcapy
#
# http://voidnetwork.org & http://void-labs.org
#-----------------------------------------------
import pcapy
import re
import binascii
import socket

class VoidSniff:
    def __init__(self, filt):
         self.device = "any"  
         self.snaplen = 2048    
         self.promisc = 1    
         self.to_ms = 100        
         self.pcap_filter = ""    
         self.max_pkts = -1        
         self.filterstring = filt
         self.p = pcapy.open_live(self.device, self.snaplen, self.promisc, self.to_ms)

    def conv(self, s):
        self.IP = str(self.hex2dec(s[0:2]))+'.'+str(self.hex2dec(s[2:4]))+'.'+\
                  str(self.hex2dec(s[4:6]))+'.'+str(self.hex2dec(s[6:8]))
        return self.IP

    def hex2dec(self, x):
        return int('0x'+x, 0)

    def packethandler(self, hdr, data):
        if re.search(self.filterstring, data):
            contain = binascii.b2a_hex(data)
            ip_s = self.conv(contain[56:64])
            try:
                dom_s = socket.getfqdn(ip_s)
            except:
                dom_s = ip_s
            try:
                logger = open('block.log','a+')
            except:
                print 'file not found'
            else:
                if re.search(dom_s,logger.read()):
                    pass
                else:
                    logger.write(dom_s+'\n')
                    print 'Logged IP: '+dom_s
                    logger.close()
            print '[+] alert! '
            # u can add prevention method after found the pattern attack

    def run(self):
         self.p.setfilter(self.pcap_filter)
         self.p.loop(self.max_pkts, self.packethandler)

if __name__ == '__main__':
    filt = raw_input('filter string : ')
    v_sniff = VoidSniff(filt)
    v_sniff.run()
Visit this user's website Find all posts by this user
Quote this message in a reply
11-17-2010, 09:23 AM
Post: #2
ian182 Offline
DC Senior
***
Posts: 425
Joined: Dec 2009
Reputation: 14
RE: Simple Network Intrussion Detection System with .py
keren broo :-bd
Visit this user's website Find all posts by this user
Quote this message in a reply
11-17-2010, 01:08 PM
Post: #3
darmawan Offline
./Devilz Officer
Posts: 229
Joined: Aug 2010
Reputation: 0
RE: Simple Network Intrussion Detection System with .py
ini buat apa n cra mkek nya gmna y kk;prustasi
Visit this user's website Find all posts by this user
Quote this message in a reply
11-17-2010, 02:17 PM (This post was last modified: 11-17-2010 02:24 PM by 5ynL0rd.)
Post: #4
5ynL0rd Offline
DC Senior
***
Posts: 53
Joined: Oct 2010
Reputation: 14
RE: Simple Network Intrussion Detection System with .py
ok mungkin buat yg awam bgt pasti bingung gw tuh ngomong apaan sih.. :)

skrg gw jelasin secara singkat dan mudah2n jelas.

NIDS (Network Intrussion Detection System) itu kasarnya pengembangan dari firewall yg biasa kita pake, kata "Detection" memberikan definisi bahwa NIDS hanya bisa memberikan alert jika paket di dalam jaringan diindikasikan berbahaya (NIDS punya pattern utk tau paket2 bahaya ini behaviournya seperti apa, contoh: ada paket TCP dgn flagbit SYN yg banyak dlm waktu yg singkat [anggap lah itu cth pola dari SYN flood. Mungkin temen2 disini pada jago kalo soal itu]), nah script ini hanya potongan singkat gimana NIDS bekerja. Mungkin pada tau SNORT kan yg logonya gbr babi?! nah kasarnya ini implementasi sangat sederhana dari si snort.

Script python ini cukup dieksekusi biasa seperti script python lainnya di mesin Linux kalian. script akan tanya string apa yg akan difilter (misal: "sex"). setelah script running silahkan dites menggunakan protokol apapun (kecuali SSL. karena pasti isi paketnya di encrypt). masukkan kata "sex" (contoh: lu buka YM terus tulis status lu ada kata "sex" nya, atau browsing http [bkn https] yg ada konten string "sex" nya), nanti script akan capture dan kasih warning (disini saya tambah juga utk record IP source + IP destination dari paket yg kontennya ada string "sex" tadi ke log file "block.log")

nah.. ini bisa kalian kembangkan ke state big apps. Kita bisa buat SNORT versi kita sendiri bukan? so gimana kalo kita gabung record IP ini kemudian datanya kita passing ke rule iptables utk blok IP tersebut.. hasilnya jadi NIPS (Network Intrussion Prevention System. Ada kata "Prevent" yg tidak hanya alert saja, tapi sudah bertindak/melakukan sesuatu, yaitu membuat rule iptables secara dinamis [bisa berubah2 tergantung scripting kita])

cukup singkat dan jelas penjelasannya? klo utk syntax ada baiknya baca2 tulisan2 gw entah dimana itu mengenai python klo emg tertarik development.

happy coding devilzc0ders :)

regards:
5ynL0rd
founder of http://voidnetwork.org & http://void-labs.org
tambahan mungkin, ada baiknya script ini di develop dan di running di router (posisi tempat hilir mudik paket) so paket yg ga diinginkan masuk ke DMZ (kasarnya jaringan intern) pun bisa diantisipasi.

nb: tanpa di develop ulang pun scriptnya jalan sih tapi sangat sederhana. hanya parsing content paketnya, catat ke log, trus ada treak2 'alert!' di prompt anda :) belum sampe parsing header protokolnya lebih detail utk siapin pattern2 yg diindikasikan attacker.
Visit this user's website Find all posts by this user
Quote this message in a reply
01-06-2011, 02:26 AM
Post: #5
zer03s Online
ExploiteR devilzc0de
Posts: 1,330
Joined: Jan 2010
Reputation: 33
RE: Simple Network Intrussion Detection System with .py
keren om mantap
Visit this user's website Find all posts by this user
Quote this message in a reply
01-07-2011, 10:01 PM
Post: #6
lordvalkyrie Offline
./Devilz 1st Cadet
Posts: 5
Joined: Jan 2011
Reputation: 0
RE: Simple Network Intrussion Detection System with .py
woooww , nice share kak !
Find all posts by this user
Quote this message in a reply
01-08-2011, 09:59 AM
Post: #7
3ono Offline
./Devilz Officer
Posts: 211
Joined: Jan 2010
Reputation: 0
RE: Simple Network Intrussion Detection System with .py
mantab kk.....
Find all posts by this user
Quote this message in a reply
01-20-2011, 04:44 PM
Post: #8
pyhx0r Offline
./Devilz 1st Cadet
Posts: 19
Joined: Jan 2011
Reputation: 1
RE: Simple Network Intrussion Detection System with .py
Keren, ayo sama2 dukung biar ID punya juga NIDS. Di void-labs, ini masuk project utama gak kk? Saya tertarik ni ma ni project :)
Visit this user's website Find all posts by this user
Quote this message in a reply
« Next Oldest | Next Newest »
Post Reply 


Topic Tools
Topic Link :
BBCode :
HTML Code :
View a Printable Version Send Thread to a Friend Subscribe to this thread
Submit Google Submit Face book Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Jeqq

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  New tool from indonesianbacktrack - simple phpmyadmin dictionary attack mywisdom 3 228 01-10-2013 08:16 PM
Last Post: haXna
  simple python.cgi buat back connect ev1lut10n 6 1,671 10-27-2012 08:58 AM
Last Post: sec0day
  [cherrypy]simple buat web schumbag 14 1,590 07-21-2012 07:01 AM
Last Post: monyett
  Simple Python Keylogger ubuntux 9 1,003 06-24-2012 07:49 AM
Last Post: ubuntux
  Simple Network Intrussion Prevention System (Ping Flooding Case) 5ynL0rd 9 619 04-27-2012 07:52 PM
Last Post: 5ynL0rd
  voidbot (IRC bot simple example with python) 5ynL0rd 8 2,452 11-29-2010 11:01 AM
Last Post: mariachi
  simple RAT with .py 5ynL0rd 4 1,335 11-18-2010 10:35 AM
Last Post: fernando

Users Browsing
1 Guest(s)

  • Contact Us
  • devilzc0de
  • Return to Top
  • Mobile Version
  • RSS Syndication
  • Help
Current time: 05-18-2013, 08:22 PM Powered By MyBB, © 2002-2013 MyBB Group. Theme created by Justin S. | Mixed By Chaer.Newbie | Fixed By Aditya

USING THIS SITE INDICATES THAT YOU HAVE READ AND ACCEPT OUR TERMS. IF YOU DO NOT ACCEPT THESE TERMS, YOU ARE NOT AUTHORIZED TO USE THIS SITE