模拟登录脚本之搬瓦工bandwagonhost
2023-02-18 16:44:18 时间
老早写的,都忘了当初想干啥了。。。。
半成品,留个坑,待填。
#!/usr/bin/env python
# encoding: utf-8
import cookielib
import requests
def http_send(url, post_data='', **kwargs):
cookie_handler = cookielib.MozillaCookieJar('cookie.txt')
try:
cookie_handler.load(ignore_discard=1)
except cookielib.LoadError, e:
print e + "new cookie file"
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36'}
if post_data:
req = requests.post(url, data=post_data, cookies=cookie_handler)
else:
req = requests.get(url)
print req.headers
for c in req.cookies:
cookie_handler.set_cookie(c)
cookie_handler.save(ignore_discard=1)
return req.content
if __name__ == '__main__':
# init cookie
print http_send('http://localhost/clientarea.php', {"A": 1})
#!/usr/bin/env python
# encoding: utf-8
import cookielib
import requests
from bs4 import BeautifulSoup
import logging
import logging.handlers
import os
import re
logging.basicConfig(filename=os.path.join(os.getcwd(), 'log.txt'), level=logging.DEBUG)
s = requests.session()
def main():
do_login()
scan_list()
check()
def do_login():
global headers, username, password
# get token
# token_html = s.get(login_url).content
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 '
'(KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36'}
token_html = open('C:\Users\Administrator\Desktop\index.html').read()
token = find_token(token_html)
post_data = {'token': token, 'username': username, 'password': password}
s.post(affiliates_url, post_data)
print s.content
def find_token(html):
g = re.findall('name="token"\svalue="(\w+)"\s/>', html)
if g:
return g[0]
else:
log("Could not find token value!")
raise Exception('Could not find token value')
def scan_list():
print 111
def check():
print 111
def log(msg):
logging.debug(msg)
if __name__ == '__main__':
# 初始化参数
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36'}
login_url = "https://bandwagonhost.com/clientarea.php"
affiliates_url = "https://bandwagonhost.com/affiliates.php"
username = 1111
password = 2222
main()
相关文章
- 4步教你学会使用Linux-Audit工具
- 10种有用的Linux Bash_Completion 命令示例
- Ubuntu & GitLab CI & Docker & ASP.NET Core 2.0 自动化发布和部署(2)
- 实践GoF的设计模式:迭代器模式
- 【补充】Gitlab 部署 CI 持续集成
- Google Chrome 应用商店上传扩展程序
- 实践GoF的23种设计模式:观察者模式
- Ubuntu Docker 安装和配置 GitLab CI 持续集成
- Ubuntu 简单安装和配置 GitLab
- 二进制SCA指纹提取黑科技:Go语言逆向技术
- 解读Go分布式链路追踪实现原理
- 基于C#的MongoDB数据库开发应用(4)--Redis的安装及使用
- 基于C#的MongoDB数据库开发应用(3)--MongoDB数据库的C#开发之异步接口
- 基于C#的MongoDB数据库开发应用(1)--MongoDB数据库的基础知识和使用
- Linux 常用命令(持续补充)
- 云小课|3种常用Git工作流推荐
- 实践GoF的23种设计模式:装饰者模式
- git bisect:让你闭眼都能定位疑难 bug的利器
- 通用权限管理系统多语言开发标准接口 - java,php 调用标准接口程序参考
- 收到Sybase公司PowerDesigner产品的律师函后,只能改进一下思路了