Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F31716108
raw.txt
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
kolbert
Mar 30 2020, 10:50 PM
2020-03-30 22:50:55 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
raw.txt
View Options
#!/usr/bin/env python
import json
import requests
import sys
from requests_oauthlib import OAuth1
#Script takes in the block length as a command-line argument
script, length = sys.argv
METAWIKI_API = 'https://meta.wikimedia.org/w/api.php'
def make_request(api, payload, post=False):
config = json.loads(open('config.json').read())
auth = OAuth1(config['customer_token'], config['customer_secret'], config['access_token'], config['access_secret'])
if post:
return requests.post(api, data=payload, auth=auth)
else:
return requests.get(api, params=payload, auth=auth)
ips = open('ips.txt', 'r').read().split('\n')
for ip in ips:
print('Blocking %s, open proxy' % ip)
r = make_request(METAWIKI_API, {
"action": "query",
"format": "json",
"meta": "tokens",
"type": "csrf"
})
token = r.json()['query']['tokens']['csrftoken']
r = make_request(METAWIKI_API, {
"action": "globalblock",
"format": "json",
"target": ip,
"expiry": length,
"reason": "[[m:NOP|Open proxy]]",
"token": token
})
r = make_request(METAWIKI_API, {
"action": "query",
"format": "json",
"meta": "tokens",
"type": "csrf"
})
token = r.json()['query']['tokens']['csrftoken']
r = make_request(METAWIKI_API, {
"action": "block",
"format": "json",
"target": ip,
"expiry": length,
"reason": "[[m:NOP|Open proxy]]",
"nocreate": 1,
"autoblock": 1,
"token": token
})
ips.close()
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
8365102
Default Alt Text
raw.txt (1 KB)
Attached To
Mode
P10821 (An Untitled Masterwork)
Attached
Detach File
Event Timeline
Log In to Comment