Skip to content

Instantly share code, notes, and snippets.

@m8sec
Last active December 27, 2023 21:19
Show Gist options
  • Save m8sec/ecf9c7b5f1a38db8de37f3425e4b4782 to your computer and use it in GitHub Desktop.
Save m8sec/ecf9c7b5f1a38db8de37f3425e4b4782 to your computer and use it in GitHub Desktop.

Revisions

  1. m8sec revised this gist Jul 12, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pastebin_api.py
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/usr/bin/env python2.7

    # Author: m8r0wn
    # Description: Python script to interact with Pastebin API
    # Description: Python class to interact with Pastebin API

    import urllib2
    import urllib
  2. m8sec revised this gist Jun 8, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions pastebin_api.py
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/usr/bin/env python2.7

    #Author: m8r0wn
    #Description: Python script to interact with Pastebin API
    # Author: m8r0wn
    # Description: Python script to interact with Pastebin API

    import urllib2
    import urllib
  3. m8sec revised this gist Jun 8, 2018. 1 changed file with 2 additions and 7 deletions.
    9 changes: 2 additions & 7 deletions pastebin_api.py
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,7 @@
    #!/usr/bin/env python2.7

    # Author: m8r0wn

    # Description:
    # Code to interact with the pastebin API

    # Disclaimer:
    # Use at your own risk.
    #Author: m8r0wn
    #Description: Python script to interact with Pastebin API

    import urllib2
    import urllib
  4. m8sec renamed this gist Mar 12, 2018. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion paste_it.py → pastebin_api.py
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,6 @@
    #!/usr/bin/env python2.7

    # Author: m8r0wn
    # Script: paste_it.py

    # Description:
    # Code to interact with the pastebin API
  5. m8sec revised this gist Feb 2, 2018. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion paste_it.py
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,6 @@

    # Author: m8r0wn
    # Script: paste_it.py
    # Category: Info Gathering

    # Description:
    # Code to interact with the pastebin API
  6. Mike revised this gist Jan 5, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions paste_it.py
    Original file line number Diff line number Diff line change
    @@ -122,8 +122,8 @@ def scraper_paste_metadata(self, paste_key):
    req = urllib2.urlopen('https://pastebin.com/api_scrape_item_meta.php?i=' + paste_key, timeout=7)
    return req.read()

    #Exampl Usage:
    #List trending pastes
    #Example Usage:
    #List trending pastes
    try:
    paste = paste_it()
    print paste.list_trending()
  7. Mike revised this gist Dec 1, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion paste_it.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    #!/user/bin/python2.7
    #!/usr/bin/env python2.7

    # Author: m8r0wn
    # Script: paste_it.py
  8. m8r0wn revised this gist Sep 28, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion paste_it.py
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    # Author: m8r0wn
    # Script: paste_it.py
    # Category: API
    # Category: Info Gathering

    # Description:
    # Code to interact with the pastebin API
  9. m8r0wn revised this gist Sep 26, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion paste_it.py
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,7 @@ def user_key(self):
    return req.read().decode()

    def list_trending(self):
    #list Trending Pastes, max of 18results allowed:
    #list Trending Pastes, max of 18 results allowed:
    api_option = 'trends'
    data = {'api_dev_key':self.api_dev_key,
    'api_option':api_option}
  10. m8r0wn revised this gist Sep 26, 2017. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions paste_it.py
    Original file line number Diff line number Diff line change
    @@ -34,11 +34,10 @@ def user_key(self):
    return req.read().decode()

    def list_trending(self):
    #list Trending Pastes:
    #list Trending Pastes, max of 18results allowed:
    api_option = 'trends'
    data = {'api_dev_key':self.api_dev_key,
    'api_option':api_option,
    'api_results_limit':self.api_results_limit}
    'api_option':api_option}
    req = urllib2.urlopen('https://pastebin.com/api/api_post.php', urllib.urlencode(data).encode('utf-8'),timeout=7)
    return req.read()

  11. m8r0wn revised this gist Sep 26, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion paste_it.py
    Original file line number Diff line number Diff line change
    @@ -40,7 +40,7 @@ def list_trending(self):
    'api_option':api_option,
    'api_results_limit':self.api_results_limit}
    req = urllib2.urlopen('https://pastebin.com/api/api_post.php', urllib.urlencode(data).encode('utf-8'),timeout=7)
    return req.read().decode()
    return req.read()

    def apiuser_pastes(self):
    #list API user's Pastes:
  12. m8r0wn revised this gist Sep 13, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion paste_it.py
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    # Author: m8r0wn
    # Script: paste_it.py
    # Category: Recon
    # Category: API

    # Description:
    # Code to interact with the pastebin API
  13. m8r0wn revised this gist Sep 12, 2017. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions paste_it.py
    Original file line number Diff line number Diff line change
    @@ -125,5 +125,8 @@ def scraper_paste_metadata(self, paste_key):

    #Exampl Usage:
    #List trending pastes
    paste = paste_it()
    print paste.list_trending()
    try:
    paste = paste_it()
    print paste.list_trending()
    except Exception as e:
    print "[!] API Error:",e
  14. m8r0wn revised this gist Sep 12, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion paste_it.py
    Original file line number Diff line number Diff line change
    @@ -108,7 +108,7 @@ def create_paste(self,data):
    req = urllib2.urlopen('https://pastebin.com/api/api_post.php', urllib.urlencode(data).encode('utf-8'),timeout=7)
    return req.read().decode()

    #The following require your source IP address to be white-listed
    #The following requires your source IP address to be white-listed
    def scraper(self):
    #Fetch most recent pastes
    #Add ?limit=# to limit responses, max=250, default=50
  15. m8r0wn created this gist Sep 12, 2017.
    129 changes: 129 additions & 0 deletions paste_it.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,129 @@
    #!/user/bin/python2.7

    # Author: m8r0wn
    # Script: paste_it.py
    # Category: Recon

    # Description:
    # Code to interact with the pastebin API

    # Disclaimer:
    # Use at your own risk.

    import urllib2
    import urllib

    class paste_it():
    #Class Variables

    #Pastebin API Key
    api_dev_key = ''
    #Pastebin Username
    username = ''
    #Pastebin Password
    password = ''
    #Max results
    api_results_limit = 25 #default=50, min=1, max=1000

    def user_key(self):
    #create user key
    user_key_data = {'api_dev_key':self.api_dev_key,
    'api_user_name':self.username,
    'api_user_password':self.password}
    req = urllib2.urlopen('https://pastebin.com/api/api_login.php', urllib.urlencode(user_key_data).encode('utf-8'), timeout=7)
    return req.read().decode()

    def list_trending(self):
    #list Trending Pastes:
    api_option = 'trends'
    data = {'api_dev_key':self.api_dev_key,
    'api_option':api_option,
    'api_results_limit':self.api_results_limit}
    req = urllib2.urlopen('https://pastebin.com/api/api_post.php', urllib.urlencode(data).encode('utf-8'),timeout=7)
    return req.read().decode()

    def apiuser_pastes(self):
    #list API user's Pastes:
    api_option = 'list'
    data = data = {'api_dev_key':self.api_dev_key,
    'api_user_key':self.user_key(),
    'api_option':api_option,
    'api_results_limit':self.api_results_limit}
    req = urllib2.urlopen('https://pastebin.com/api/api_post.php', urllib.urlencode(data).encode('utf-8'), timeout=7)
    return req.read().decode()

    def apiuser_details(self):
    #list API user's details:
    api_option = 'userdetails'
    data = {'api_dev_key': self.api_dev_key,
    'api_user_key': self.user_key(),
    'api_option': api_option,
    'api_results_limit': self.api_results_limit}
    req = urllib2.urlopen('https://pastebin.com/api/api_post.php', urllib.urlencode(data).encode('utf-8'), timeout=7)
    return req.read().decode()

    def show_apiuser_paste(self, paste_key):
    #Print Raw paste created by api_user
    api_option = 'show_paste'
    api_paste_key = paste_key
    data = {'api_dev_key':self.api_dev_key,
    'api_user_key':self.user_key(),
    'api_option':api_option,
    'api_paste_key':api_paste_key}
    req = urllib2.urlopen('https://pastebin.com/api/api_raw.php', urllib.urlencode(data).encode('utf-8'),timeout=7)
    return req.read().decode()

    def show_paste(self, paste_key):
    #Print Raw paste
    req = urllib2.urlopen('https://pastebin.com/raw/'+paste_key, timeout=7)
    return req.read()

    def delete_paste(self, paste_key):
    #Delete one of API user's pastes
    api_option = 'delete'
    api_paste_key = paste_key
    data = {'api_dev_key': self.api_dev_key,
    'api_user_key': self.user_key(),
    'api_option': api_option,
    'api_paste_key': api_paste_key}
    req = urllib2.urlopen('https://pastebin.com/api/api_post.php', urllib.urlencode(data).encode('utf-8'),timeout=7)
    return req.read().decode()

    def create_paste(self,data):
    #Create paste on api user's account
    api_option = 'paste'
    api_paste_code = data #paste text body
    api_paste_private = 0 #0=public, 1=unlisted, 2=private
    api_paste_name = 'title' #title of paste
    api_paste_expire_data = 'N' #available: N=never, 10M=10min, 1H=1hour, 1D=1Day, 1W=1week, 2W=2weeks, 1M=1Month, 6M=6months, 1Y=1year
    api_paste_format = 'text' #text=None, mysql-MYSQL, perl=Perl, python=Python, sql=SQL, vbscript=VBscript, xml=XML, html4strict=HTML, html5=HTML5,
    data = {'api_dev_key':self.api_dev_key,
    'api_user_key':self.user_key(),
    'api_option':api_option,
    'api_paste_code':api_paste_code,
    'api_paste_private':api_paste_private,
    'api_paste_name':api_paste_name,
    'api_paste_expire_data':api_paste_expire_data,
    'api_paste_format':api_paste_format}
    req = urllib2.urlopen('https://pastebin.com/api/api_post.php', urllib.urlencode(data).encode('utf-8'),timeout=7)
    return req.read().decode()

    #The following require your source IP address to be white-listed
    def scraper(self):
    #Fetch most recent pastes
    #Add ?limit=# to limit responses, max=250, default=50
    req = urllib2.urlopen('https://pastebin.com/api_scraping.php',timeout=7)
    return req.read()

    def scraper_paste(self, paste_key):
    req = urllib2.urlopen('https://pastebin.com/api_scrape_item.php?i=' + paste_key, timeout=7)
    return req.read()

    def scraper_paste_metadata(self, paste_key):
    req = urllib2.urlopen('https://pastebin.com/api_scrape_item_meta.php?i=' + paste_key, timeout=7)
    return req.read()

    #Exampl Usage:
    #List trending pastes
    paste = paste_it()
    print paste.list_trending()