1 | commit 31ee5d3a5273142e3467e71dd8a1485db1dc8ec3 |
2 | Author: acidvegas <acid.vegas@acid.vegas> |
3 | Date: Fri Jun 28 01:28:33 2019 -0400 |
4 | |
5 | Initial commit |
6 | --- |
7 | LICENSE | 15 +++ |
8 | README.md | 11 ++ |
9 | pastebin/example.py | 32 +++++ |
10 | pastebin/pastebin.py | 328 +++++++++++++++++++++++++++++++++++++++++++++++++++ |
11 | 4 files changed, 386 insertions(+) |
12 | |
13 | diff --git a/LICENSE b/LICENSE |
14 | new file mode 100644 |
15 | index 0000000..69997e8 |
16 | --- /dev/null |
17 | +++ b/LICENSE |
18 | @@ -0,0 +1,15 @@ |
19 | +ISC License |
20 | + |
21 | +Copyright (c) 2019, acidvegas <acid.vegas@acid.vegas> |
22 | + |
23 | +Permission to use, copy, modify, and/or distribute this software for any |
24 | +purpose with or without fee is hereby granted, provided that the above |
25 | +copyright notice and this permission notice appear in all copies. |
26 | + |
27 | +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
28 | +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
29 | +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
30 | +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
31 | +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
32 | +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
33 | +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
34 | diff --git a/README.md b/README.md |
35 | new file mode 100644 |
36 | index 0000000..366cbcc |
37 | --- /dev/null |
38 | +++ b/README.md |
39 | @@ -0,0 +1,11 @@ |
40 | +###### Requirements |
41 | +* [Python](https://www.python.org/downloads/) *(**Note:** This script was developed to be used with the latest version of Python.)* |
42 | + |
43 | +###### API Documentation: |
44 | +* [Pastebin API](https://pastebin.com/api) |
45 | + |
46 | +###### Mirrors |
47 | +- [acid.vegas](https://acid.vegas/pastebin) *(main)* |
48 | +- [SuperNETs](https://git.supernets.org/acidvegas/pastebin) |
49 | +- [GitHub](https://github.com/acidvegas/pastebin) |
50 | +- [GitLab](https://gitlab.com/acidvegas/pastebin) |
51 | diff --git a/pastebin/example.py b/pastebin/example.py |
52 | new file mode 100644 |
53 | index 0000000..7675a2d |
54 | --- /dev/null |
55 | +++ b/pastebin/example.py |
56 | @@ -0,0 +1,32 @@ |
57 | +#!/usr/bin/env python |
58 | +# PasteBin API Class - Developed by acidvegas in Python (https://acid.vegas/pastebin) |
59 | + |
60 | +import getpass |
61 | + |
62 | +import pastebin |
63 | + |
64 | +# API Settings |
65 | +api_dev_key = 'CHANGEME' |
66 | +api_user_key = None |
67 | + |
68 | +# Define API |
69 | +if api_user_key: |
70 | + api = pastebin.PasteBin(api_dev_key, api_user_key) |
71 | +else: |
72 | + api = pastebin.PasteBin(api_dev_key) |
73 | + username = input('[?] - Username: ') |
74 | + password = getpass.getpass('[?] - Password: ') |
75 | + api_user_key = api.create_user_key(username, password) |
76 | + if 'Bad API request' not in api_user_key: |
77 | + print('[+] - You API user key is: ' + ap_user_key) |
78 | + api = pastebin.PasteBin(api_dev_key, api_user_key) |
79 | + else: |
80 | + raise SystemExit('[!] - Failed to create API user key! ({0})'.format(api_user_key.split(', ')[1])) |
81 | + |
82 | +# Create a Paste |
83 | +data = open(__file__).read() |
84 | +result = api.paste(data, guest=True, name='Example Script', format='Python', private='1', expire='10M') |
85 | +if 'Bad API request' not in result: |
86 | + print('[+] - PasteBin URL: ' + result) |
87 | +else: |
88 | + raise SystemExit('[!] - Failed to create paste! ({0})'.format(api_user_key.split(', ')[1])) |
89 | diff --git a/pastebin/pastebin.py b/pastebin/pastebin.py |
90 | new file mode 100644 |
91 | index 0000000..15bb26a |
92 | --- /dev/null |
93 | +++ b/pastebin/pastebin.py |
94 | @@ -0,0 +1,328 @@ |
95 | +#!/usr/bin/env python |
96 | +# PasteBin API Class - Developed by acidvegas in Python (https://acid.vegas/pastebin) |
97 | + |
98 | +''' |
99 | +API Documentation: |
100 | + https://pastebin.com/api |
101 | +''' |
102 | + |
103 | +import urllib.parse |
104 | +import urllib.request |
105 | + |
106 | +# Values |
107 | +format_values = { |
108 | + '4cs' : '4CS', |
109 | + '6502acme' : '6502 ACME Cross Assembler', |
110 | + '6502kickass' : '6502 Kick Assembler', |
111 | + '6502tasm' : '6502 TASM/64TASS', |
112 | + 'abap' : 'ABAP', |
113 | + 'actionscript' : 'ActionScript', |
114 | + 'actionscript3' : 'ActionScript 3', |
115 | + 'ada' : 'Ada', |
116 | + 'aimms' : 'AIMMS', |
117 | + 'algol68' : 'ALGOL 68', |
118 | + 'apache' : 'Apache Log', |
119 | + 'applescript' : 'AppleScript', |
120 | + 'apt_sources' : 'APT Sources', |
121 | + 'arm' : 'ARM', |
122 | + 'asm' : 'ASM (NASM)', |
123 | + 'asp' : 'ASP', |
124 | + 'asymptote' : 'Asymptote', |
125 | + 'autoconf' : 'autoconf', |
126 | + 'autohotkey' : 'Autohotkey', |
127 | + 'autoit' : 'AutoIt', |
128 | + 'avisynth' : 'Avisynth', |
129 | + 'awk' : 'Awk', |
130 | + 'bascomavr' : 'BASCOM AVR', |
131 | + 'bash' : 'Bash', |
132 | + 'basic4gl' : 'Basic4GL', |
133 | + 'dos' : 'Batch', |
134 | + 'bibtex' : 'BibTeX', |
135 | + 'blitzbasic' : 'Blitz Basic', |
136 | + 'b3d' : 'Blitz3D', |
137 | + 'bmx' : 'BlitzMax', |
138 | + 'bnf' : 'BNF', |
139 | + 'boo' : 'BOO', |
140 | + 'bf' : 'BrainFuck', |
141 | + 'c' : 'C', |
142 | + 'c_winapi' : 'C (WinAPI)', |
143 | + 'c_mac' : 'C for Macs', |
144 | + 'cil' : 'C Intermediate Language', |
145 | + 'csharp' : 'C#', |
146 | + 'cpp' : 'C++', |
147 | + 'cpp-winapi' : 'C++ (WinAPI)', |
148 | + 'cpp-qt' : 'C++ (with Qt extensions)', |
149 | + 'c_loadrunner' : 'C: Loadrunner', |
150 | + 'caddcl' : 'CAD DCL', |
151 | + 'cadlisp' : 'CAD Lisp', |
152 | + 'ceylon' : 'Ceylon', |
153 | + 'cfdg' : 'CFDG', |
154 | + 'chaiscript' : 'ChaiScript', |
155 | + 'chapel' : 'Chapel', |
156 | + 'clojure' : 'Clojure', |
157 | + 'klonec' : 'Clone C', |
158 | + 'klonecpp' : 'Clone C++', |
159 | + 'cmake' : 'CMake', |
160 | + 'cobol' : 'COBOL', |
161 | + 'coffeescript' : 'CoffeeScript', |
162 | + 'cfm' : 'ColdFusion', |
163 | + 'css' : 'CSS', |
164 | + 'cuesheet' : 'Cuesheet', |
165 | + 'd' : 'D', |
166 | + 'dart' : 'Dart', |
167 | + 'dcl' : 'DCL', |
168 | + 'dcpu16' : 'DCPU-16', |
169 | + 'dcs' : 'DCS', |
170 | + 'delphi' : 'Delphi', |
171 | + 'oxygene' : 'Delphi Prism (Oxygene)', |
172 | + 'diff' : 'Diff', |
173 | + 'div' : 'DIV', |
174 | + 'dot' : 'DOT', |
175 | + 'e' : 'E', |
176 | + 'ezt' : 'Easytrieve', |
177 | + 'ecmascript' : 'ECMAScript', |
178 | + 'eiffel' : 'Eiffel', |
179 | + 'email' : 'Email', |
180 | + 'epc' : 'EPC', |
181 | + 'erlang' : 'Erlang', |
182 | + 'euphoria' : 'Euphoria', |
183 | + 'fsharp' : 'F#', |
184 | + 'falcon' : 'Falcon', |
185 | + 'filemaker' : 'Filemaker', |
186 | + 'fo' : 'FO Language', |
187 | + 'f1' : 'Formula One', |
188 | + 'fortran' : 'Fortran', |
189 | + 'freebasic' : 'FreeBasic', |
190 | + 'freeswitch' : 'FreeSWITCH', |
191 | + 'gambas' : 'GAMBAS', |
192 | + 'gml' : 'Game Maker', |
193 | + 'gdb' : 'GDB', |
194 | + 'genero' : 'Genero', |
195 | + 'genie' : 'Genie', |
196 | + 'gettext' : 'GetText', |
197 | + 'go' : 'Go', |
198 | + 'groovy' : 'Groovy', |
199 | + 'gwbasic' : 'GwBasic', |
200 | + 'haskell' : 'Haskell', |
201 | + 'haxe' : 'Haxe', |
202 | + 'hicest' : 'HicEst', |
203 | + 'hq9plus' : 'HQ9 Plus', |
204 | + 'html4strict' : 'HTML', |
205 | + 'html5' : 'HTML 5', |
206 | + 'icon' : 'Icon', |
207 | + 'idl' : 'IDL', |
208 | + 'ini' : 'INI file', |
209 | + 'inno' : 'Inno Script', |
210 | + 'intercal' : 'INTERCAL', |
211 | + 'io' : 'IO', |
212 | + 'ispfpanel' : 'ISPF Panel Definition', |
213 | + 'j' : 'J', |
214 | + 'java' : 'Java', |
215 | + 'java5' : 'Java 5', |
216 | + 'javascript' : 'JavaScript', |
217 | + 'jcl' : 'JCL', |
218 | + 'jquery' : 'jQuery', |
219 | + 'json' : 'JSON', |
220 | + 'julia' : 'Julia', |
221 | + 'kixtart' : 'KiXtart', |
222 | + 'kotlin' : 'Kotlin', |
223 | + 'latex' : 'Latex', |
224 | + 'ldif' : 'LDIF', |
225 | + 'lb' : 'Liberty BASIC', |
226 | + 'lsl2' : 'Linden Scripting', |
227 | + 'lisp' : 'Lisp', |
228 | + 'llvm' : 'LLVM', |
229 | + 'locobasic' : 'Loco Basic', |
230 | + 'logtalk' : 'Logtalk', |
231 | + 'lolcode' : 'LOL Code', |
232 | + 'lotusformulas' : 'Lotus Formulas', |
233 | + 'lotusscript' : 'Lotus Script', |
234 | + 'lscript' : 'LScript', |
235 | + 'lua' : 'Lua', |
236 | + 'm68k' : 'M68000 Assembler', |
237 | + 'magiksf' : 'MagikSF', |
238 | + 'make' : 'Make', |
239 | + 'mapbasic' : 'MapBasic', |
240 | + 'markdown' : 'Markdown', |
241 | + 'matlab' : 'MatLab', |
242 | + 'mirc' : 'mIRC', |
243 | + 'mmix' : 'MIX Assembler', |
244 | + 'modula2' : 'Modula 2', |
245 | + 'modula3' : 'Modula 3', |
246 | + '68000devpac' : 'Motorola 68000 HiSoft Dev', |
247 | + 'mpasm' : 'MPASM', |
248 | + 'mxml' : 'MXML', |
249 | + 'mysql' : 'MySQL', |
250 | + 'nagios' : 'Nagios', |
251 | + 'netrexx' : 'NetRexx', |
252 | + 'newlisp' : 'newLISP', |
253 | + 'nginx' : 'Nginx', |
254 | + 'nimrod' : 'Nimrod', |
255 | + 'text' : 'None', |
256 | + 'nsis' : 'NullSoft Installer', |
257 | + 'oberon2' : 'Oberon 2', |
258 | + 'objeck' : 'Objeck Programming Langua', |
259 | + 'objc' : 'Objective C', |
260 | + 'ocaml-brief' : 'OCalm Brief', |
261 | + 'ocaml' : 'OCaml', |
262 | + 'octave' : 'Octave', |
263 | + 'oorexx' : 'Open Object Rexx', |
264 | + 'pf' : 'OpenBSD PACKET FILTER', |
265 | + 'glsl' : 'OpenGL Shading', |
266 | + 'oobas' : 'Openoffice BASIC', |
267 | + 'oracle11' : 'Oracle 11', |
268 | + 'oracle8' : 'Oracle 8', |
269 | + 'oz' : 'Oz', |
270 | + 'parasail' : 'ParaSail', |
271 | + 'parigp' : 'PARI/GP', |
272 | + 'pascal' : 'Pascal', |
273 | + 'pawn' : 'Pawn', |
274 | + 'pcre' : 'PCRE', |
275 | + 'per' : 'Per', |
276 | + 'perl' : 'Perl', |
277 | + 'perl6' : 'Perl 6', |
278 | + 'php' : 'PHP', |
279 | + 'php-brief' : 'PHP Brief', |
280 | + 'pic16' : 'Pic 16', |
281 | + 'pike' : 'Pike', |
282 | + 'pixelbender' : 'Pixel Bender', |
283 | + 'pli' : 'PL/I', |
284 | + 'plsql' : 'PL/SQL', |
285 | + 'postgresql' : 'PostgreSQL', |
286 | + 'postscript' : 'PostScript', |
287 | + 'povray' : 'POV-Ray', |
288 | + 'powershell' : 'Power Shell', |
289 | + 'powerbuilder' : 'PowerBuilder', |
290 | + 'proftpd' : 'ProFTPd', |
291 | + 'progress' : 'Progress', |
292 | + 'prolog' : 'Prolog', |
293 | + 'properties' : 'Properties', |
294 | + 'providex' : 'ProvideX', |
295 | + 'puppet' : 'Puppet', |
296 | + 'purebasic' : 'PureBasic', |
297 | + 'pycon' : 'PyCon', |
298 | + 'python' : 'Python', |
299 | + 'pys60' : 'Python for S60', |
300 | + 'q' : 'q/kdb+', |
301 | + 'qbasic' : 'QBasic', |
302 | + 'qml' : 'QML', |
303 | + 'rsplus' : 'R', |
304 | + 'racket' : 'Racket', |
305 | + 'rails' : 'Rails', |
306 | + 'rbs' : 'RBScript', |
307 | + 'rebol' : 'REBOL', |
308 | + 'reg' : 'REG', |
309 | + 'rexx' : 'Rexx', |
310 | + 'robots' : 'Robots', |
311 | + 'rpmspec' : 'RPM Spec', |
312 | + 'ruby' : 'Ruby', |
313 | + 'gnuplot' : 'Ruby Gnuplot', |
314 | + 'rust' : 'Rust', |
315 | + 'sas' : 'SAS', |
316 | + 'scala' : 'Scala', |
317 | + 'scheme' : 'Scheme', |
318 | + 'scilab' : 'Scilab', |
319 | + 'scl' : 'SCL', |
320 | + 'sdlbasic' : 'SdlBasic', |
321 | + 'smalltalk' : 'Smalltalk', |
322 | + 'smarty' : 'Smarty', |
323 | + 'spark' : 'SPARK', |
324 | + 'sparql' : 'SPARQL', |
325 | + 'sqf' : 'SQF', |
326 | + 'sql' : 'SQL', |
327 | + 'standardml' : 'StandardML', |
328 | + 'stonescript' : 'StoneScript', |
329 | + 'sclang' : 'SuperCollider', |
330 | + 'swift' : 'Swift', |
331 | + 'systemverilog' : 'SystemVerilog', |
332 | + 'tsql' : 'T-SQL', |
333 | + 'tcl' : 'TCL', |
334 | + 'teraterm' : 'Tera Term', |
335 | + 'thinbasic' : 'thinBasic', |
336 | + 'typoscript' : 'TypoScript', |
337 | + 'unicon' : 'Unicon', |
338 | + 'uscript' : 'UnrealScript', |
339 | + 'upc' : 'UPC', |
340 | + 'urbi' : 'Urbi', |
341 | + 'vala' : 'Vala', |
342 | + 'vbnet' : 'VB.NET', |
343 | + 'vbscript' : 'VBScript', |
344 | + 'vedit' : 'Vedit', |
345 | + 'verilog' : 'VeriLog', |
346 | + 'vhdl' : 'VHDL', |
347 | + 'vim' : 'VIM', |
348 | + 'visualprolog' : 'Visual Pro Log', |
349 | + 'vb' : 'VisualBasic', |
350 | + 'visualfoxpro' : 'VisualFoxPro', |
351 | + 'whitespace' : 'WhiteSpace', |
352 | + 'whois' : 'WHOIS', |
353 | + 'winbatch' : 'Winbatch', |
354 | + 'xbasic' : 'XBasic', |
355 | + 'xml' : 'XML', |
356 | + 'xorg_conf' : 'Xorg Config', |
357 | + 'xpp' : 'XPP', |
358 | + 'yaml' : 'YAML', |
359 | + 'z80' : 'Z80 Assembler', |
360 | + 'zxbasic' : 'ZXBasic' |
361 | +} |
362 | + |
363 | +expire_values = { |
364 | + 'N' : 'Never', |
365 | + '10M' : '10 Minutes', |
366 | + '1H' : '1 Hour', |
367 | + '1D' : '1 Day', |
368 | + '1W' : '1 Week', |
369 | + '2W' : '2 Weeks', |
370 | + '1M' : '1 Month' |
371 | +} |
372 | + |
373 | +private_values = { |
374 | + '0' : 'Public', |
375 | + '1' : 'Unlisted', |
376 | + '2' : 'Private' |
377 | +} |
378 | + |
379 | +class PasteBin: |
380 | + def __init__(self, api_dev_key, api_user_key=None, timeout=10): |
381 | + self.api_dev_key = api_dev_key |
382 | + self.api_user_key = api_user_key |
383 | + self.timeout = timeout |
384 | + |
385 | + def api_call(self, method, params): |
386 | + response = urllib.request.urlopen('https://pastebin.com/api/' + method, urllib.parse.urlencode(params).encode('utf-8'), timeout=self.timeout) |
387 | + return response.read().decode() |
388 | + |
389 | + def create_user_key(self, username, password): |
390 | + params = {'api_dev_key':self.api_dev_key, 'api_user_name':username, 'api_user_password':password} |
391 | + return api_call('api_login.php', params) |
392 | + |
393 | + def paste(self, data, guest=False, name=None, format=None, private=None, expire=None): |
394 | + params = {'api_dev_key':self.api_dev_key, 'api_option':'paste', 'api_paste_code':data} |
395 | + if not guest : params['api_user_key'] = self.api_user_key |
396 | + if name : params['api_paste_name'] = name |
397 | + if format : params['api_paste_format'] = format |
398 | + if private : params['api_paste_private'] = private |
399 | + if expire : params['api_paste_expire_date'] = expire |
400 | + return self.api_call('api_post.php', params) |
401 | + |
402 | + def list_pastes(self, results_limit=None): |
403 | + params = {'api_dev_key':self.api_dev_key, 'api_user_key':self.api_user_key, 'api_option':'list'} |
404 | + if results_limit: # Default 50, Minimum 1, Maximum 1000 |
405 | + params['api_results_limit'] = results_limit |
406 | + return self.api_call('api_post.php', params) |
407 | + |
408 | + def trending_pastes(self): |
409 | + params = {'api_dev_key':self.api_dev_key, 'api_option':'trends'} |
410 | + return self.api_call('api_post.php', params) |
411 | + |
412 | + def delete_paste(self, paste_key): |
413 | + params = {'api_dev_key':self.api_dev_key, 'api_user_key':self.api_user_key, 'api_paste_key':paste_key, 'api_option':'delete'} |
414 | + return self.api_call('api_post.php', params) |
415 | + |
416 | + def user_info(self): |
417 | + params = {'api_dev_key':self.api_dev_key, 'api_user_key':self.api_user_key, 'api_option':'userdetails'} |
418 | + return self.api_call('api_post.php', params) |
419 | + |
420 | + def raw_pastes(self, paste_key): |
421 | + params = {'api_dev_key':self.api_dev_key, 'api_user_key':self.api_user_key, 'api_paste_key':paste_key, 'api_option':'show_paste'} |
422 | + return self.api_call('api_raw.php', params) |