Little update cleaning stuff up
This commit is contained in:
parent
e4a8566077
commit
6d593523a6
26
README.md
26
README.md
@ -1,11 +1,25 @@
|
||||
###### Requirements
|
||||
* [Python](https://www.python.org/downloads/) *(**Note:** This script was developed to be used with the latest version of Python.)*
|
||||
# pastebin
|
||||
> python wrapper for the pastebin api
|
||||
|
||||
###### API Documentation:
|
||||
* [Pastebin API](https://pastebin.com/api)
|
||||
## API Documentation:
|
||||
* [Pastebin API](https://pastebin.com/doc_api)
|
||||
* [Pastebin Scraping API](https://pastebin.com/doc_scraping_api)
|
||||
|
||||
###### Mirrors
|
||||
- [acid.vegas](https://acid.vegas/pastebin) *(main)*
|
||||
## Example:
|
||||
```python
|
||||
#!/usr/bin/env python
|
||||
import pastebin
|
||||
api_dev_key = 'CHANGEME'
|
||||
api = pastebin.PasteBin(api_dev_key)
|
||||
data = open(__file__).read()
|
||||
result = api.paste(data, guest=True, name='Example Script', format='Python', private='1', expire='10M')
|
||||
print('PasteBin URL: ' + result)
|
||||
```
|
||||
|
||||
**Note**: A posix shell script example can be found [here](https://github.com/acidvegas/random/blob/master/pastebin)
|
||||
|
||||
## Mirrors
|
||||
- [acid.vegas](https://git.acid.vegas/pastebin)
|
||||
- [SuperNETs](https://git.supernets.org/acidvegas/pastebin)
|
||||
- [GitHub](https://github.com/acidvegas/pastebin)
|
||||
- [GitLab](https://gitlab.com/acidvegas/pastebin)
|
||||
|
@ -1,9 +1,10 @@
|
||||
#!/usr/bin/env python
|
||||
# PasteBin API Class - Developed by acidvegas in Python (https://acid.vegas/pastebin)
|
||||
# PasteBin API Class - Developed by acidvegas in Python (https://git.acid.vegas/pastebin)
|
||||
|
||||
'''
|
||||
API Documentation:
|
||||
https://pastebin.com/api
|
||||
https://pastebin.com/doc_api
|
||||
https://pastebin.com/doc_scraping_api
|
||||
'''
|
||||
|
||||
import urllib.parse
|
||||
@ -283,13 +284,13 @@ private_values = {
|
||||
}
|
||||
|
||||
class PasteBin:
|
||||
def __init__(self, api_dev_key, api_user_key=None, timeout=10):
|
||||
def __init__(self, api_dev_key, api_user_key=None):
|
||||
self.api_dev_key = api_dev_key
|
||||
self.api_user_key = api_user_key
|
||||
self.timeout = timeout
|
||||
|
||||
def api_call(self, method, params):
|
||||
response = urllib.request.urlopen('https://pastebin.com/api/' + method, urllib.parse.urlencode(params).encode('utf-8'), timeout=self.timeout)
|
||||
response = urllib.request.urlopen('https://pastebin.com/api/' + method, urllib.parse.urlencode(params).encode('utf-8'), timeout=10)
|
||||
return response.read().decode()
|
||||
|
||||
def create_user_key(self, username, password):
|
@ -1,32 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# PasteBin API Class - Developed by acidvegas in Python (https://acid.vegas/pastebin)
|
||||
|
||||
import getpass
|
||||
|
||||
import pastebin
|
||||
|
||||
# API Settings
|
||||
api_dev_key = 'CHANGEME'
|
||||
api_user_key = None
|
||||
|
||||
# Define API
|
||||
if api_user_key:
|
||||
api = pastebin.PasteBin(api_dev_key, api_user_key)
|
||||
else:
|
||||
api = pastebin.PasteBin(api_dev_key)
|
||||
username = input('[?] - Username: ')
|
||||
password = getpass.getpass('[?] - Password: ')
|
||||
api_user_key = api.create_user_key(username, password)
|
||||
if 'Bad API request' not in api_user_key:
|
||||
print('[+] - You API user key is: ' + api_user_key)
|
||||
api = pastebin.PasteBin(api_dev_key, api_user_key)
|
||||
else:
|
||||
raise SystemExit('[!] - Failed to create API user key! ({0})'.format(api_user_key.split(', ')[1]))
|
||||
|
||||
# Create a Paste
|
||||
data = open(__file__).read()
|
||||
result = api.paste(data, guest=True, name='Example Script', format='Python', private='1', expire='10M')
|
||||
if 'Bad API request' not in result:
|
||||
print('[+] - PasteBin URL: ' + result)
|
||||
else:
|
||||
raise SystemExit('[!] - Failed to create paste! ({0})'.format(api_user_key.split(', ')[1]))
|
Loading…
Reference in New Issue
Block a user