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

Script sederhana buat upload source file ke pastebin

Home General Computer Multimedia Business Lounge

Pages (2): 1 2 Next »
Post Reply 
Tweet
Threaded Mode | Linear Mode
Script sederhana buat upload source file ke pastebin
02-05-2012, 05:12 PM
Post: #1
ditatompel Offline
Administrator
*******
Administrators
Posts: 2,168
Joined: Dec 2010
Reputation: 367
Script sederhana buat upload source file ke pastebin
Misi om... Ane mo share script buat upload source file ke pastebin.com pake pastebin API.
Maaf klo berantakan, baru belajar Python soalnya. Mohon koreksinya. asik
Namanya passtobin.py ngakak
Berikut penampakannya :
[Image: passtobin.png]
Berikut sourcecodenya :
http://pastebin.com/f28PjK4z

Code:
#!/usr/bin/python
# passtobin.py v 0.1
# Uploads source file to pastebin.com using pastebin API.
# You may use custom filename, post as guest / user
# with private / public paste option and auto syntax
# highlight for several filetypes, etc.
#
# coded by: ditatompel <ditatompel@gmail.com>
# Thanks to : 5ynL0rd who always inspire me.
# Greetings for all members of devilzc0de.org, all Indonesian c0ders,
# and all GNU Generation ;-)
# I glue you all my regards.

from optparse import OptionParser
import sys, getpass, urllib, string, os.path

# Login as user and get your API http://pastebin.com/api
# But it's ok you use API key below. ;)
APIKEY = "81a5d31a05abe09be32cb6832f6904b9"
URL = "http://pastebin.com"

menu = OptionParser()
menu.add_option("-f", dest="file", help="file you want to upload (Required!) ")
menu.add_option("-u", "--user", dest="user", help="your pastebin username, will be submit as guest if not specified", type="string")
menu.add_option("-n", "--name", dest="name", default='untitled', help="your pastebin file title (optional)")
menu.add_option("-p", "--private", action="store_false", default="0", help="set this param for private paste")
menu.add_option("-t", "--type", dest="type", default='text', help="force format syntax highlight (Default: text)")
menu.add_option("-e", dest="expire_date", default='N', help="Paste expires. Default: Never", metavar="<N|10M|1H|1D|1M>")

ExpOpt = { "N": "never", "10M": "10 minutes", "1H": "1 hour", "1D": "1 day", "1M": "1 month" }

FileType = {
    "4cs": "4CS", "6502acme": "6502 ACME Cross Assembler", "6502kickass": "6502 Kick Assembler",
    "6502tasm": "6502 TASM/64TASS", "abap": "ABAP", "actionscript": "ActionScript",
    "actionscript3": "ActionScript 3", "ada": "Ada", "algol68": "ALGOL 68", "apache": "Apache Log",
    "applescript": "AppleScript", "apt_sources": "APT Sources", "asm": "ASM (NASM)", "asp" : "ASP",
    "autoconf": "autoconf", "autohotkey": "Autohotkey", "autoit": "AutoIt", "avisynth": "Avisynth",
    "awk": "Awk", "bascomavr": "BASCOM AVR", "bash": "Bash", "basic4gl": "Basic4GL",
    "bibtex": "BibTeX", "blitzbasic": "Blitz Basic", "bnf": "BNF", "boo": "BOO", "bf": "BrainFuck",
    "c": "C", "c_mac": "C for Macs", "cil": "C Intermediate Language", "csharp": "C#",
    "cpp": "C++", "cpp-qt": "C++ (with QT extensions)", "c_loadrunner": "C: Loadrunner",
    "caddcl": "CAD DCL", "cadlisp": "CAD Lisp", "cfdg": "CFDG", "chaiscrip": "ChaiScript",
    "clojure": "Clojure", "klonec": "Clone C", "klonecpp": "Clone C++", "cmake": "CMake",
    "cobol": "COBOL", "coffeescript": "CoffeeScript", "cfm": "ColdFusion", "css": "CSS",
    "cuesheet": "Cuesheet", "d": "D", "dcs": "DCS", "delphi": "Delphi",
    "oxygene": "Delphi Prism (Oxygene)", "diff": "Diff", "div": "DIV", "dos": "DOS",
    "dot": "DOT", "e": "E", "ecmascript": "ECMAScript", "eiffel": "Eiffel", "email": "Email",
    "epc": "EPC", "erlang": "Erlang", "fsharp": "F#", "falcon": "Falcon", "fo": "FO Language",
    "f1": "Formula One", "fortran": "Fortran", "freebasic": "FreeBasic", "freeswitch": "FreeSWITCH",
    "gambas": "GAMBAS", "gml": "Game Maker", "gdb": "GDB", "genero": "Genero", "genie": "Genie",
    "gettext": "GetText", "go": "Go", "groovy": "Groovy", "gwbasic": "GwBasic", "haskell": "Haskell",
    "hicest": "HicEst", "hq9plus": "HQ9 Plus", "html4strict": "HTML", "html5": "HTML 5", "icon": "Icon",
    "idl": "IDL", "ini": "INI file", "inno": "Inno Script", "intercal": "INTERCAL", "io": "IO", "j": "J",
    "java": "Java", "java5": "Java 5", "javascript": "JavaScript", "jquery": "jQuery",
    "kixtart": "KiXtart", "latex": "Latex", "lb": "Liberty BASIC", "lsl2": "Linden Scripting",
    "lisp": "Lisp", "llvm": "LLVM", "locobasic": "Loco Basic", "logtalk": "Logtalk",
    "lolcode": "LOL Code", "lotusformulas": "Lotus Formulas", "lotusscript": "Lotus Script",
    "lscript": "LScript", "lua": "Lua", "m68k": "M68000 Assembler", "magiksf": "MagikSF", "make": "Make",
    "mapbasic": "MapBasic", "matlab": "MatLab", "mirc": "mIRC", "mmix": "MIX Assembler",
    "modula2": "Modula 2", "modula3": "Modula 3", "68000devpac": "Motorola 68000 HiSoft Dev",
    "mpasm": "MPASM", "mxml": "MXML", "mysql": "MySQL", "newlisp": "newLISP", "text": "None",
    "nsis": "NullSoft Installer", "oberon2": "Oberon 2", "objeck": "Objeck Programming Langua",
    "objc": "Objective C", "ocaml-brief": "OCalm Brief", "ocaml": "OCaml", "pf": "OpenBSD PACKET FILTER",
    "glsl": "OpenGL Shading", "oobas": "Openoffice BASIC", "oracle11": "Oracle 11", "oracle8": "Oracle 8",
    "oz": "Oz", "pascal": "Pascal", "pawn": "PAWN", "pcre": "PCRE", "per": "Per", "perl": "Perl",
    "perl6": "Perl 6", "php": "PHP", "php-brief": "PHP Brief", "pic16": "Pic 16", "pike": "Pike",
    "pixelbender": "Pixel Bender", "plsql": "PL/SQL", "postgresql": "PostgreSQL", "povray": "POV-Ray",
    "powershell": "Power Shell", "powerbuilder": "PowerBuilder", "proftpd": "ProFTPd",
    "progress": "Progress", "prolog": "Prolog", "properties": "Properties", "providex": "ProvideX",
    "purebasic": "PureBasic", "pycon": "PyCon", "python": "Python", "q": "q/kdb+", "qbasic": "QBasic",
    "rsplus": "R", "rails": "Rails", "rebol": "REBOL", "reg": "REG", "robots": "Robots",
    "rpmspec": "RPM Spec", "ruby": "Ruby", "gnuplot": "Ruby Gnuplot", "sas": "SAS", "scala": "Scala",
    "scheme": "Scheme", "scilab": "Scilab", "sdlbasic": "SdlBasic", "smalltalk": "Smalltalk",
    "smarty": "Smarty", "sql": "SQL", "systemverilog": "SystemVerilog", "tsql": "T-SQL", "tcl": "TCL",
    "teraterm": "Tera Term", "thinbasic": "thinBasic", "typoscript": "TypoScript", "unicon": "Unicon",
    "uscript": "UnrealScript", "vala": "Vala", "vbnet": "VB.NET", "verilog": "VeriLog", "vhdl": "VHDL",
    "vim": "VIM", "visualprolog": "Visual Pro Log", "vb": "VisualBasic", "visualfoxpro": "VisualFoxPro",
    "whitespace": "WhiteSpace", "whois": "WHOIS", "winbatch": "Winbatch", "xbasic": "XBasic", "xml": "XML",
    "xorg_conf": "Xorg Config", "xpp": "XPP", "yaml": "YAML", "z80": "Z80 Assembler", "zxbasic": "ZXBasic"
}

try:
    (options, args) = menu.parse_args()
    
    if options.file:
        f = open(options.file, 'r')
        fileU = f.read()
    else:
        menu.print_help()
        sys.exit(1)
    
    if options.user:
        password = getpass.getpass("pastebin Password:")
        user = options.user
    else:
        user = "guest"
    
    if options.private:
        private = "0"
    else:
        private = "1"
    
    if options.expire_date:
        if options.expire_date not in ExpOpt:
            print "invalid paste expires argument!\nUse following syntax :"
            for Opts in ExpOpt:
                print Opts + " \t=> " + ExpOpt[Opts]
            sys.exit(1)

except IOError, err:
    if "directory" in str(err[1]):
        print "[!]\tCan't open file " + options.file
        sys.exit(1)
    else:
        print "[!]\t" + err[1]
        sys.exit(1)

def getCodeType():
    ext = os.path.splitext(options.file)[1]
    syntax = "text"
    AutoExts = {
        ".4cs": "4cs", ".abap": "abap", ".as": "actionscript", ".asm": "asm",
        ".asp": "asp", ".sh": "bash", ".cs": "csharp", ".c": "c", ".cpp": "cpp",
        ".css": "css", ".html": "html4strict", ".h": "c", ".java": "java",
        ".js": "javascript", ".LUA": "lua", ".php": "php", ".pl": "perl",
        ".py": "python", ".sql": "sql"
        }
    for AutoExt in AutoExts:
        if AutoExt == ext:
            syntax = AutoExts[AutoExt]
    
    return syntax

def PasteIt(paste_name, paste_format, paste_code, paste_private, paste_expire):
    if user != "guest":
        LoginParam = urllib.urlencode({'api_dev_key': APIKEY,
        'api_user_name': user,
        'api_user_password': password
        })
        PostLogin = urllib.urlopen(URL + '/api/api_login.php',LoginParam)
        try:
            LoginRespond = PostLogin.read()
            if "Bad API" in LoginRespond:
                print "[!] Error : " + LoginRespond
                sys.exit(1)
            else:
                PasteParam = urllib.urlencode({'api_option': 'paste',
                'api_user_key': LoginRespond,
                'api_dev_key': APIKEY,
                'api_paste_name': paste_name,
                'api_paste_format': paste_format,
                'api_paste_code': paste_code,
                'api_paste_private': paste_private,
                'api_paste_expire_date': paste_expire
                })
        finally:
            PostLogin.close()
    
    else:
        PasteParam = urllib.urlencode({'api_option': 'paste',
        'api_dev_key': APIKEY,
        'api_paste_name': paste_name,
        'api_paste_format': paste_format,
        'api_paste_code': paste_code,
        'api_paste_private': paste_private,
        'api_paste_expire_date': paste_expire
        })
    
    PostPaste = urllib.urlopen(URL + '/api/api_post.php',PasteParam)
    try :
        response = PostPaste.read()
        print response
    finally:
        PostPaste.close()

if __name__ == "__main__":
    if options.type != "text":
        if options.type not in FileType:
            print options.type + " syntax is not available on pastebin, using default filetype syntax.."
            UsedSyntax = getCodeType()
        else:
            UsedSyntax = options.type
    else:
        UsedSyntax = getCodeType()
    print "[+] File : " + options.file
    print "[+] Syntax : " + UsedSyntax
    print "[+] post as : " + user
    print "[+] Expires : " + ExpOpt[options.expire_date]
    PasteIt(options.name, UsedSyntax, fileU, private, options.expire_date)

Contoh penggunaan :
Code:
python passtobin.py -f /path/to/file/upload.txt

Code:
Options:
  -h, --help            show this help message and exit
  -f FILE               file you want to upload (Required!)
  -u USER, --user=USER  your pastebin username, will be submit as guest if not
                        specified
  -n NAME, --name=NAME  your pastebin file title (optional)
  -p, --private         set this param for private paste
  -t TYPE, --type=TYPE  force format syntax highlight (Default: text)
  -e <N|10M|1H|1D|1M>   Paste expires. Default: Never

-h atau --help
untuk menampilkan opsi dan cara penggunaan.

-f FILE ( Required ! )
Lokasi file yang ingin diupload ke pastebin.com

-u USER atau --user=USER ( Optional )
Username pastebin kamu. Klo tidak di set usernya, maka otomatis bakal nge-paste sebagai guest.

-n NAME atau --name="Judul file" ( Optional )
Nama judul file yang bakal munjul di "title" pastebin. Klo ga diisi, maka judulnya akan nge-paste dengan judul "untitled"

-t TYPE atau --type=TYPE ( Optional )
Untuk force syntax highlight yg digunakan. Jika tidak di set, maka script akan coba otomatis medeteksi dari ekstensi file tersebut.
Untuk sementara support untuk auto detect ekstensi yang ada pada line 121 - 127.
Secara default, jika file ekstensi tidak ada pada list diatas, maka akan menggunakan format text ( tanpa syntax highlight )
Untuk force type lebih lengkapnya bisa dilihat pada http://pastebin.com/api

-e ( Optional )
Brapa lama file tersebut akan ada di pastebin.com.
untuk expires option :
Quote:N = Never ( Default )
10M = 10 Minutes
1H = 1 Hour
1D = 1 Day
1M = 1 Month

-p atau --private
Private paste. Max untuk 1 akun free pastebin 25 private paste.

Nah misal saya ingin upload private file dengan format apache log ke pastebin menggunakan user ditatompel expires selama 1 hari dengan judul paste "Apache Log Jan 2012" Maka :

Code:
$ python passtobin.py -f /var/log/httpd/error_log -u ditatompel -t apache -e 1D -n "Apache Log Jan 2012" --private

Nah, mungkin sampe disini dulu.. Silahkan klo mo diperbaiki / dikaembangkan karena script di atas masih sebatas upload saja. asik

Akhir kata,
/me Male, 17 thn tipe pria SIAGA (Siap Antem Pakai Gaya Apa Saja) mimisan
Find all posts by this user
Quote this message in a reply
 Reputed by :  hipokrit(+1) , eidelweiss(+1) , nanda(+1) , CitooZz(+1) , rusuh(+1) , ketek(+1) , schumbag(+1)
02-05-2012, 05:22 PM (This post was last modified: 02-05-2012 05:24 PM by Killu4.)
Post: #2
Killu4 Away
./Devilz Advisor
Posts: 744
Joined: Nov 2011
Reputation: 16
RE: Script sederhana buat upload source file ke pastebin
Quote:f FILE ( Required ! )
Lokasi file yang ingin diupload ke pastebin.com

Yg ini maksudnya path filenya yaa,misal lokasi filenya ada di :
B:\Python\Script XSS

penulisannya lokasinya benar ga om kya gitu ? CMIIW ketawa

Ane Pertamax ngakak
Find all posts by this user
Quote this message in a reply
02-05-2012, 05:25 PM
Post: #3
ditatompel Offline
Administrator
*******
Administrators
Posts: 2,168
Joined: Dec 2010
Reputation: 367
RE: Script sederhana buat upload source file ke pastebin
(02-05-2012 05:22 PM)Killu4 Wrote:  
Quote:f FILE ( Required ! )
Lokasi file yang ingin diupload ke pastebin.com

Yg ini maksudnya path filenya yaa,misal lokasi filenya ada di :
B:\Python\Script XSS

penulisannya lokasinya benar ga om kya gitu ? CMIIW ketawa
Iya gitu.. Masalahnya ane lom sempet coba di windus om.. hammer
Jalan ga di windows? ngakak
Find all posts by this user
Quote this message in a reply
02-05-2012, 05:25 PM
Post: #4
eidelweiss Offline
Devilzc0der
*****
DC Security Grup
Posts: 1,535
Joined: Mar 2010
Reputation: 69
RE: Script sederhana buat upload source file ke pastebin
o0o..

buat ini toh yg di tanya di sotbox tadi malem

mantap
Visit this user's website Find all posts by this user
Quote this message in a reply
02-05-2012, 05:28 PM
Post: #5
Killu4 Away
./Devilz Advisor
Posts: 744
Joined: Nov 2011
Reputation: 16
RE: Script sederhana buat upload source file ke pastebin
(02-05-2012 05:25 PM)ditatompel Wrote:  Iya gitu.. Masalahnya ane lom sempet coba di windus om.. hammer
Jalan ga di windows? ngakak

Wakakakak baiklah ane coba dlu,ntar ane balik lg buat kasih laporannya om hore
Find all posts by this user
Quote this message in a reply
02-05-2012, 05:41 PM
Post: #6
ditatompel Offline
Administrator
*******
Administrators
Posts: 2,168
Joined: Dec 2010
Reputation: 367
RE: Script sederhana buat upload source file ke pastebin
(02-05-2012 05:25 PM)eidelweiss Wrote:  o0o..

buat ini toh yg di tanya di sotbox tadi malem

mantap

Iya om.. ngakak


(02-05-2012 05:28 PM)Killu4 Wrote:  
(02-05-2012 05:25 PM)ditatompel Wrote:  Iya gitu.. Masalahnya ane lom sempet coba di windus om.. hammer
Jalan ga di windows? ngakak

Wakakakak baiklah ane coba dlu,ntar ane balik lg buat kasih laporannya om hore

Oke om.. mantap
ditunggu reportnya.. asik
Find all posts by this user
Quote this message in a reply
02-05-2012, 05:48 PM
Post: #7
sunafets.exe Offline
./Devilz Commander
Posts: 297
Joined: Aug 2011
Reputation: 4
RE: Script sederhana buat upload source file ke pastebin
download phyton runtime nya....

... lamaaaaaaaaaaaaaaaaaaaaa............... ngambek
Find all posts by this user
Quote this message in a reply
02-05-2012, 06:47 PM (This post was last modified: 02-05-2012 06:48 PM by schumbag.)
Post: #8
schumbag Offline
nothing special about me
***
Posts: 800
Joined: Jan 2010
Reputation: 51
RE: Script sederhana buat upload source file ke pastebin
baru ini regist ke pastebin karena emang pengen tau kayak gimana sih pastebin itu -___-
Code:
schumbag@ngelux:~/whoami$ ./ditom.py -f serv.py -u anjaw -n server-socket.py -e15D
pastebin Password:
invalid paste expires argument!
Use following syntax :
1H     => 1 hour
10M     => 10 minutes
1M     => 1 month
1D     => 1 day
N     => never
schumbag@ngelux:~/whoami$ ./ditom.py -f serv.py -u anjaw -n server-socket.py -e1M
pastebin Password:
[+] File : serv.py
[+] Syntax : python
[+] post as : anjaw
[+] Expires : 1 month
http://pastebin.com/pWkeTU9p

pilihannya cuma
Quote:1H => 1 hour
10M => 10 minutes
1M => 1 month
1D => 1 day
N => never
jadi nggak ada randomize misal mo di jadikan brapa hari untuk expire
kayak 15D tadi gak bisa dead
Quote:uummmmmm punya linggis gak??
*dita : gak punya
kl no hp ada dong?? mimisan
ntar om,kl udah di rumah koneksi stabil ane coba tambahin fitur buat expired nya piss
masih ngedate ama darkslayer di ancol ____________ngacir
dari tadi nge-load gk kelar2 dead
Find all posts by this user
Quote this message in a reply
02-05-2012, 07:29 PM
Post: #9
ditatompel Offline
Administrator
*******
Administrators
Posts: 2,168
Joined: Dec 2010
Reputation: 367
RE: Script sederhana buat upload source file ke pastebin
Ngga bisa kek klo Yg expire dibuat custom.. Soalnya ane baca di http://pastebin.com/api cuma ada 5 pilihan itu. ketawa

No hp punya kek.. tp kaga inget.. ngakak... maling
Find all posts by this user
Quote this message in a reply
02-05-2012, 07:35 PM
Post: #10
rusuh Away
sepik'ers
**
Moderators
Posts: 455
Joined: Oct 2011
Reputation: 77
RE: Script sederhana buat upload source file ke pastebin
(02-05-2012 07:29 PM)ditatompel Wrote:  Ngga bisa kek klo Yg expire dibuat custom.. Soalnya ane baca di http://pastebin.com/api cuma ada 5 pilihan itu. ketawa

No hp punya kek.. tp kaga inget.. ngakak... maling

gw sih inget kalo mau ngakak
Visit this user's website 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
  simple python.cgi buat back connect ev1lut10n 6 1,676 10-27-2012 08:58 AM
Last Post: sec0day
  [uler kadut]script sederhana membuat proses timeout ce.dealova 22 4,241 08-04-2012 08:16 PM
Last Post: perlman
  [cherrypy]simple buat web schumbag 14 1,592 07-21-2012 07:01 AM
Last Post: monyett
  Mengubah .chm ke satu file .html (phyton) wenkhairu 4 1,511 07-20-2012 10:48 PM
Last Post: asong123
  ScriptFinder.py, Searches for file contains dangerous command ditatompel 10 1,456 03-01-2012 08:55 PM
Last Post: badwolves1986
  contoh pemindahan posisi pointer file ce.dealova 5 1,073 02-24-2012 02:16 AM
Last Post: Fauzi Topan
Star Script untuk download semua gambar dari tumblr ketek 25 2,226 02-20-2012 04:01 PM
Last Post: coreflood
  [Tutor] VKDownloader Python Script p0pc0rn 8 858 01-27-2012 05:49 PM
Last Post: ketek
  kill script masokis 4 935 05-15-2011 03:34 PM
Last Post: flame_1221
  [python]buat belajar regex kiddies 6 1,586 01-20-2011 05:10 PM
Last Post: pyhx0r

Users Browsing
1 Guest(s)

  • Contact Us
  • devilzc0de
  • Return to Top
  • Mobile Version
  • RSS Syndication
  • Help
Current time: 05-20-2013, 01:57 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