Devilzc0de Forum Follow @devilzc0de
  • Home
  • Hacking
  • Networking
  • Programming
  • O.S
  • Server
  • Tweets
  • Search
  • Member List
  • Calendar
Current time: 06-20-2013, 09:38 AM Hello There, Guest! (Login — Register)
Devilzc0de Forum › Information Technology › Programming › Python v
« Previous 1 2 3 4 Next »

ScriptFinder.py, Searches for file contains dangerous command

Home General Computer Multimedia Business Lounge

Pages (2): 1 2 Next »
Post Reply 
Tweet
Threaded Mode | Linear Mode
ScriptFinder.py, Searches for file contains dangerous command
10-16-2011, 05:35 PM
Post: #1
ditatompel Offline
Administrator
*******
Administrators
Posts: 2,205
Joined: Dec 2010
Reputation: 371
ScriptFinder.py, Searches for file contains dangerous command
Misi om2 semua.. Ketemu lagi dengan saya.. ngakak

Ane lagi belajar python nih om.. Nah ini tools pertama yang ane.
Ni tools gunanya untuk mencari "command2" berbahaya yang mungkin bisa dimanfaatkan oleh attacker untuk mendapatkan "akses lebih" dalam sebuah sistem.
Inspirasi dan beberapa line dari tools buatan om d3hydr8 darkc0de. (sitenya boleh mati, tp semangat tetap masih membara bangga)

Sekalian kado ultah buat om Ketek tanda terima kasih saya secara pribari atas dedikasinya buat Indonesia. bangga

Happy Birthday om, makasih udah share ilmu2nya. smangat

[Image: sf.png]
Nah langsung aja nih codenya :

Code:
#!/usr/bin/python
""" ScriptFinder 1.1 < ditatompel [at] gmail [dot] com >
Searches for file contains dangerous command

Inspired from tools created by d3hydr8[at]gmail[dot]com
greetz to d3hydr8, 5ynL0rd all members of devilzc0de.org,
ex darkc0de.com, all Indonesian c0ders, and all GNU Generation ;-)

PS : Happy Birthday ketek, Revres Tanur or whatever nickname gonna be :p
PF : ?? Oct ???? - ?? Oct 2011 """


import sys, re

def halo():
    print "\n" + "-+-"*30 + "\n\tScriptFinder 1.1 < ditatompel [at] gmail [dot] com >"
    print "\tSearches for file contains dangerous command"
    print "\tGreetz to all members of devilzc0de.org, ex darkc0de.com, all Indonesian c0ders,"
    print "\tand all GNU Generation ;-)\n" + "-+-"*30+"\n"

def usage():
    print "\tUsage: python " + sys.argv[0] + " <dir>"
    print "\tExample: python " + sys.argv[0] + " /home/ditatompel/public_html\n"
    sys.exit(1)

#Original from d3hydr8[at]gmail[dot]com
def Walk( root, recurse=0, pattern='*', return_folders=0 ):
    import fnmatch, os, string

    result = []

    try:
        names = os.listdir(root)
    except os.error:
        return result

    pattern = pattern or '*'
    pat_list = string.splitfields( pattern , ';' )

    for name in names:
        fullname = os.path.normpath(os.path.join(root, name))

        for pat in pat_list:
            if fnmatch.fnmatch(name, pat):
                if os.path.isfile(fullname) or (return_folders and os.path.isdir(fullname)):
                    result.append(fullname)
                continue
        if recurse:
            if os.path.isdir(fullname) and not os.path.islink(fullname):
                result = result + Walk( fullname, recurse, pattern, return_folders )
        
    return result

def search(files, auto=0):
    
    if auto:
        searchstring = danger
    else:
        searchstring = specificstring
    
    print "\n[+] Searching:", len(files), "files"
    print "\n" + "-+-"*20 + "\n[+] files containing '" + searchstring + "' under " + sys.argv[1] + "\n"+"-+-"*20+"\n"
    love.write("\n"+"-+-"*20)
    love.write("\n[+] files containing '%s' under '%s' \n" % (searchstring, sys.argv[1]) )
    love.write("-+-"*20+"\n")
    
    for file in files:
        num = 0
        
        try:
            text = open(file, "r").readlines()
            
            for line in text:
                num +=1
                if re.search(searchstring.lower(), line.lower()):
                    print "[!] File:",file,"on Line:",num,"\n[!] Code:",line
                    love.write("""[!] File: %s on Line %s \n[!] Code: %s \n""" % (file, num, line.replace("\t","")) )
        
        except(IOError):
            pass
    
    print "[+] Done\n"

halo()

actions = [
    "base64_decode", # many php shell use this but may generate false positive result, remove this if necessary. Especially when using recursive scan.
    "exec",
    "eval", # may generate false positive result, remove this if necessary. Especially when using recursive scan.
    "escapeshellarg",
    "escapeshellcmd",
    "fpaththru",
    "getmy", # getmypid, getmygid, getmyuid, etc
    "gzinflate",
    "gzuncompress",
    "ini_alter",
    "leak",
    "mDbl8VndvJj2", # encoded devshell.asp
    "php_uname",
    "posix_", # any posix_* function
    "proc_", # any proc_* function
    "popen",
    "passthru",
    "pcntl_exec",
    "socket_accept",
    "socket_bind",
    "socket_clear_error",
    "socket_close",
    "socket_connect",
    "set_time_limit",
    "shell_exec",
    "system", # may generate false positive result, remove this if necessary. Especially when using recursive scan.
    "show_source",
    "xrunexploit" # source function on devshell.*
    ]

minus_r = 1

if len(sys.argv) < 2:
    usage()

recdir = raw_input("Recursive ? ( Y/n ): ")
mode = raw_input("Full scan Mode (Y/n): ")

if mode.lower() != "y":
    specificstring = raw_input("String to search: ")

ext = raw_input("Specific File extension to scan ( <return> to scan all extension ) : ")
filelog = raw_input("logfile ( default sf.log ): ")

if filelog == "":
    filelog = "sf.log"

if recdir.lower() != "y":
    minus_r = 0

love = open(filelog, "w")
love.write("-+-"*30 + "\n\tScriptFinder 1.1 < ditatompel [at] gmail [dot] com >\n")
love.write("\tGreetz for all members of devilzc0de.org, ex darkc0de.com, all Indonesian c0ders,\n\tand all GNU Generation ;-)\n"+"-+-"*30+"\n")

if mode.lower() == "y":
    print "\n[+] FULL SCAN MODE ENABLED...\n[+]", len(actions),"dangerous commands loaded\n[+] Target Dir:",sys.argv[1]
    print "[+] Logfile will be saved to: " + filelog
    love.write("""
    [+] FULL SCAN MODE ENABLED...
    [+] %s danger commands loaded
    [+] Target Dir: %s\n""" % (len(actions), sys.argv[1]) )
    for danger in actions :
        if ext == "":
            files = Walk(sys.argv[1], minus_r, '*', 1)
        else:
            files = Walk(sys.argv[1], minus_r, '*.'+ext+';')
        search(files, 1)
    print "[+] Logfile saved to " + filelog

else:
    print "\n[+] Target Dir: " + sys.argv[1] + "\n[+] String to search: " + specificstring
    print "[+] Logfile will be saved to: " + filelog
    love.write("""
    [+] Target Dir: %s
    [+] String to search %s\n""" % (sys.argv[1], specificstring ) )
    if ext == "":
        files = Walk(sys.argv[1], minus_r, '*', 1)
    else:
        files = Walk(sys.argv[1], minus_r, '*.'+ext+';')
    search(files)
    print "[+] Logfile saved to " + filelog

nah klo pusing ga ada syntax highlight nya bisa diliat di blog ane

Karena ni ulet tipe sensitif, download langsung aja filenya di http://ls-la.ditatompel.crayoncreative.n.../sf-1.1.py

Cara penggunaannya:
Code:
python sf-1.1.py /path/to/dir
Trus nanti ada interaktif tanya jawab gitu deh...

Recursive: untuk scan semua sub directory dari direktori yang sudah ditentukan sebelumnya
Full scan Mode: untuk scan semua command yang dianggap bahaya. Klo dijawab "Y", command2 diambil dari actions array. Klo full scan modenya dijawab "n", nanti om bakalan ditanya buat tentuin "command" apa yang mau di scan.
Specific File extension to scan: tipe file yang ingin di scan. Misal php / pl / dll. Kalau kosong brati semua file ikut di scan, termasuk jpg, gif, dll
logfile: tempat nyimpen hasil scan. Klo kosong nama filenya jadi sf.log

Moga2 berguna untuk para sysadmin, maaf klo codingnya kacau. dead

Ane cabut dulu om2 sekalian... hore
Find all posts by this user
Quote this message in a reply
10-16-2011, 06:13 PM
Post: #2
mariachi Away
has been reboot
**
Moderators
Posts: 2,441
Joined: Nov 2010
Reputation: 69
RE: ScriptFinder.py, Searches for file contains dangerous command
wes... mantep ni tool. anak2 devilzc0der makin hebat aja mantap
Find all posts by this user
Quote this message in a reply
10-16-2011, 06:16 PM
Post: #3
chaer.newbie Offline
--------------------------
*****
Dewa
Posts: 5,350
Joined: Dec 2009
Reputation: 187
RE: ScriptFinder.py, Searches for file contains dangerous command
hakakakkaa... i know you so well
Find all posts by this user
Quote this message in a reply
10-17-2011, 12:36 AM
Post: #4
selfdefense Offline
./Devilz Commodore
Posts: 1,294
Joined: Aug 2010
Reputation: 58
RE: ScriptFinder.py, Searches for file contains dangerous command
keren nih om dita.... mantap
ajarin ane dong om kodingnya.... asik

ijin ane coba y.... smiley_beer
Find all posts by this user
Quote this message in a reply
10-17-2011, 09:10 AM
Post: #5
mywisdom Offline
Administrator
*******
Administrators
Posts: 923
Joined: Dec 2009
Reputation: 51
RE: ScriptFinder.py, Searches for file contains dangerous command
horehore makasih mbak 2 tompel
Find all posts by this user
Quote this message in a reply
10-17-2011, 09:35 AM
Post: #6
Wayc0de Offline
-= Sifu Makan Sonice =-
**
Moderators
Posts: 2,994
Joined: Nov 2010
Reputation: 61
RE: ScriptFinder.py, Searches for file contains dangerous command
mantap codingnya mantap

ijin pasang dlu ah hmm
Visit this user's website Find all posts by this user
Quote this message in a reply
02-26-2012, 05:11 PM (This post was last modified: 02-26-2012 05:13 PM by ditatompel.)
Post: #7
ditatompel Offline
Administrator
*******
Administrators
Posts: 2,205
Joined: Dec 2010
Reputation: 371
RE: ScriptFinder.py, Searches for file contains dangerous command
(10-17-2011 12:36 AM)selfdefense Wrote:  keren nih om dita.... mantap
ajarin ane dong om kodingnya.... asik

ijin ane coba y.... smiley_beer

Silahken om.. smangat

(10-17-2011 09:10 AM)mywisdom Wrote:  horehore makasih mbak 2 tompel

Ane cowo tulen om.. mewek

(10-17-2011 09:35 AM)Wayc0de Wrote:  mantap codingnya mantap

ijin pasang dlu ah hmm

Yu mari om... ngakak
Find all posts by this user
Quote this message in a reply
02-29-2012, 03:42 AM (This post was last modified: 02-29-2012 03:43 AM by alessandra.)
Post: #8
alessandra Offline
i'm so lonely broken angel
Posts: 199
Joined: Feb 2012
Reputation: 48
RE: ScriptFinder.py, Searches for file contains dangerous command
bagus pythonnya mas DITA!!!!
gitu ngakunya cewek!!!hufttttt nohope
tapi sob lu tadi ngasih gua rep kenapa gua nggak bisa -,-!
Find all posts by this user
Quote this message in a reply
02-29-2012, 02:12 PM
Post: #9
jackerp Offline
./Devilz Advisor
Posts: 576
Joined: Jan 2011
Reputation: 41
RE: ScriptFinder.py, Searches for file contains dangerous command
Tool nya super kang...!!
tapi bleum ada dasar nya di Gw.... !!
masih newbietol....!!smangat tapi tepat smangat untuk belajar
Visit this user's website Find all posts by this user
Quote this message in a reply
03-01-2012, 08:50 PM
Post: #10
ditatompel Offline
Administrator
*******
Administrators
Posts: 2,205
Joined: Dec 2010
Reputation: 371
RE: ScriptFinder.py, Searches for file contains dangerous command
(02-29-2012 03:42 AM)alessandra Wrote:  bagus pythonnya mas DITA!!!!
gitu ngakunya cewek!!!hufttttt nohope
tapi sob lu tadi ngasih gua rep kenapa gua nggak bisa -,-!

ngakak Ane masih belajar tantee.. belajar
Tante share lagi dong tutorial python-nya? smangat


(02-29-2012 02:12 PM)jackerp Wrote:  Tool nya super kang...!!
tapi bleum ada dasar nya di Gw.... !!
masih newbietol....!!smangat tapi tepat smangat untuk belajar

asik Mari sama2 belajar om... smangat
Find all posts by this user
Quote this message in a reply
« Next Oldest | Next Newest »
Pages (2): 1 2 Next »
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
  Mengubah .chm ke satu file .html (phyton) wenkhairu 4 1,550 07-20-2012 10:48 PM
Last Post: asong123
  contoh pemindahan posisi pointer file ce.dealova 5 1,113 02-24-2012 02:16 AM
Last Post: Fauzi Topan
  Script sederhana buat upload source file ke pastebin ditatompel 14 1,685 02-06-2012 03:43 PM
Last Post: ditatompel

Users Browsing
1 Guest(s)

  • Contact Us
  • devilzc0de
  • Return to Top
  • Mobile Version
  • RSS Syndication
  • Help
Current time: 06-20-2013, 09:38 AM 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