perl http编程
来源:互联网 发布:java 计算bmi 编辑:程序博客网 时间:2024/06/05 05:02
Burp Proxy抓包,观察数据流过程
1. GET获取SessionID
2. Post username&password
>>perl a.pl http://localhost/login.asp
ASPSESSIONIDQSRSDQQT=JNIJLIKDNHMDAGCFLGEOGIDC; AJSTAT_ok_pages=1; AJSTAT_ok_times=1
>>cat a.pl
#!/usr/bin/perl -lw
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
use strict;
use warnings;
my $ua = new LWP::UserAgent;
my $cookie = undef;
my $host = $1 if ($ARGV[0] =~ /www.(.*)\/.*/);
my $origin = 'http://'.$host;
my $ok_page = '; AJSTAT_ok_pages=1';
my $ok_times = '; AJSTAT_ok_times=1';
my $action = '?Acton=ok';
my $post_url = $ARGV[0].$action;
###############################################################################
# 1. Get cookie for next step
###############################################################################
#$ua->agent('Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36');
$ua->default_header('User-Agent' => 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36');
$ua->default_header('Accept-Encoding' => 'gzip,deflate,sdch');
$ua->default_header('Accept-Language' => 'zh-CN,zh');
$ua->default_header('Accept' => 'textml,application/xhtml+xml,application/xml');
$ua->default_header('Host' => $host);
$ua->default_header('Referer' => $ARGV[0]);
my $request = new HTTP::Request('GET', $ARGV[0]);
my $response = $ua->request($request);
if ($response->is_success) {
$cookie = $response->header('Set-Cookie');
} else {
print $response->error_as_HTML;
}
###############################################################################
# 2. Setup the cookie
###############################################################################
if($cookie =~ /(.*)\;/){
$cookie = $1;
}else{
die "Error COOKIE: $cookie";
}
$cookie = $cookie.$ok_page.$ok_times;
print $cookie;
###############################################################################
# 3. Login using the password
###############################################################################
$ua = undef;
$ua = new LWP::UserAgent;
#$ua->agent('Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36');
$ua->default_header('Accept-Encoding' => 'gzip,deflate,sdch');
$ua->default_header('Accept-Language' => 'zh-CN,zh');
$ua->default_header('Accept' => 'textml,application/xhtml+xml,application/xml');
$ua->default_header('Host' => $host);
$ua->default_header('Referer' => $ARGV[0]);
$ua->default_header('Proxy-Connection' => 'keep-alive');
$ua->default_header('Cookie' => $cookie);
$ua->default_header('Content-Length' => '89');
$ua->default_header('Content-Type' => 'application/x-www-form-urlencoded');
$ua->default_header('Origin' => $origin);
$ua->default_header('User-Agent' => 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36');
$request = new HTTP::Request('POST', $post_url);
$request->content('username=jgjguyguj+&password=11111&cookietime=1&loginsubmit=+%B5%C7+%C2%BC+&action=login');
$response = $ua->request($request);
if ($response->is_success) {
print $response->content;
} else {
print $response->error_as_HTML;
}
- perl http编程
- perl socket编程 [perl]
- Perl LWP&HTTP
- Perl 发送http 请求。
- perl 安装AnyEvent::HTTP
- Perl的HTTP模块
- Perl网络编程
- perl编程必会
- perl web编程
- perl LWP 网络编程
- perl模组编程
- 《perl语言编程》读书笔记
- perl进行socket编程
- PERL SOCKET编程
- PERL 编程资料
- PERL SOCKET编程
- Perl 黑客编程
- perl多进程编程
- Linux umount 报 device is busy 的处理方法
- 再探java基础——零碎基础知识整理
- VC版计算器(豪华界面)
- 粒子群算法原理及C++代码实例
- 排序算法之二叉查找树排序
- perl http编程
- Android的Tab与TabHost
- 数据结构之二叉查找树
- Hook : KeUserModeCallback用法详解
- UVA 10681
- 应届生面试所需技术基础
- D3D9 Samples(16)--Pick
- 虚拟机NetworkAdapter三种方式的区别
- Git学习--> 分支管理