MITM Proxy环境搭建
MITM_Proxy环境搭建
环境要求
系统环境要求:
- Ubuntu 14.04 x64,CentOS 7 x64以上版本系统(建议使用xubuntu 14.04 x64,稳定硬件要求低)
- Python 2.7以上运行环境(MITM用Python写的)
- Pip 7.1版本以上,这个用于安装MITM Proxy
官方安装指南:http://mitmproxy.org/doc/install.html
下面以xubunut x64为例进行环境搭建
- 首先安装一个纯净版的xubuntu 14.04 x64系统,手动安装分区方法见下面链接: http://blog.chinaunix.net/uid-7547035-id-60111.html
- 设置好升级xubuntu升级服务器选择,建议选择aliyun节点或者香港中文大学节点,速度快,稳定
- 设置完毕后会提示授权以及是否立即进行更新,选择是
然后打开终端模拟器(terminial),准备开始更新系统列表和开始配置网卡,运行命令如下:
sudo apt-get update #更新远程软件仓库列表
sudo apt-get install vim git openssh-server openssh-client #安装工具vim,git,openssh-server,openssh-client
git clone https://github.com/wuxinwei/MyConfig.git #从github上clone下来我的配置信息,里面有vimrc,tmux,zsh的配置文件,我已经全部配好了,可以覆盖到/home/用户名/就可以
cp .../MyConfig/_vimrc ~/.vimrc #使用vim配置文件
sudo /etc/init.d/ssh start #启动ssh服务,ssh-server配置文件位于/ etc/ssh/sshd_config,在这里可以定义SSH的服务端口,默认端口是22,你可以自己定义成其他端口号,如222
sudo apt-get install bridge-utils #安装桥工具bridge-utils
brctl addbr br0 #添加一个网桥
brctl addif br0 eth0 #将eth0加到网桥中去
brctl addif br0 eth1 #将eth1加到网桥中去
开启IP转发功能以及其他配置sudo vim /etc/sysctl.conf
:
# 将全部内容改为如下:
#
# /etc/sysctl.conf - Configuration file for setting system variables
# See /etc/sysctl.d/ for additional system variables.
# See sysctl.conf (5) for information.
#
#kernel.domainname = example.com
# Uncomment the following to stop low-level messages on console
#kernel.printk = 3 4 1 3
##############################################################3
# Functions previously found in netbase
#
# Uncomment the next two lines to enable Spoof protection (reverse-path filter)
# Turn on Source Address Verification in all interfaces to
# prevent some spoofing attacks
#net.ipv4.conf.default.rp_filter=1
#net.ipv4.conf.all.rp_filter=1
# Uncomment the next line to enable TCP/IP SYN cookies
# See http://lwn.net/Articles/277146/
# Note: This may impact IPv6 TCP sessions too
#net.ipv4.tcp_syncookies=1
# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1
# Uncomment the next line to enable packet forwarding for IPv6
# Enabling this option disables Stateless Address Autoconfiguration
# based on Router Advertisements for this host
net.ipv6.conf.all.forwarding=1
###################################################################
# Additional settings - these settings can improve the network
# security of the host and prevent against some network attacks
# including spoofing attacks and man in the middle attacks through
# redirection. Some network environments, however, require that these
# settings are disabled so review and enable them as needed.
#
# Do not accept ICMP redirects (prevent MITM attacks)
net.ipv4.conf.all.accept_redirects = 0
net.ipv6.conf.all.accept_redirects = 0
# _or_
# Accept ICMP redirects only for gateways listed in our default
# gateway list (enabled by default)
# net.ipv4.conf.all.secure_redirects = 1
net.ipv4.conf.all.secure_redirects = 0
#
# Do not send ICMP redirects (we are not a router)
#net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.all.send_redirects = 0
#
# Do not accept IP source route packets (we are not a router)
#net.ipv4.conf.all.accept_source_route = 0
#net.ipv6.conf.all.accept_source_route = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv6.conf.all.accept_source_route = 0
#
# Log Martian Packets
#net.ipv4.conf.all.log_martians = 1
#
配置网桥sudo vim /etc/network/interfaces//以管理员权限打开网络配置文件
:
# 把全部文件内容改为如下:
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto eth0 #网卡eth0
iface eth0 inet manual #设置eth0网卡为手动配置,这样不会自动获取ip配置等
auto eth1 #网卡eth1
iface eth1 inet manual #设置eth0网卡为手动配置,这样不会自动获取ip配置等
auto br0 #网桥0
iface br0 inet static #设置网桥br0为静态,这样不会变化ip
address 192.168.4.144 #这里设置网桥IP
netmask 255.255.255.0 #设置网桥子网掩码
broadcast 192.168.4.255 #设置网桥广播地址
gateway 192.168.4.2 #这是网桥网关
dns-nameservers 202.96.128.86 #设置网桥DNS
bridge_ports eth0 eth1 //将eth0 和eth1网卡添加如网桥中去
bridge_stp off
brideg_hello 2
bridge_fd 9
bridge_maxwait 0
设置防火墙(注意,这里的iptables
设置在重启系统后会失效,所以如果重启过机器这里需要重新设置):
echo 0 | sudo tee /proc/sys/net/ipv4/conf/*/send_redirects
*/
service iptables start #开启iptables过滤服务
service iptables save
iptables -t nat -A PREROUTING -i br0 -p tcp --dport 80 -j REDIRECT --to-port 8080 #将80端口转发给8080
iptables -t nat -A PREROUTING -i br0 -p tcp --dport 443 -j REDIRECT --to-port 8080 #将443端口数据转发给8080
service iptables save
官方透明代理设置教程:
http://mitmproxy.org/doc/transparent/linux.html(物理机设置)
http://mitmproxy.org/doc/tutorials/transparent-dhcp.html(虚拟机设置)
经过以上配置,实现了建立网桥,打开路由转发功能(用于MITM的透明代理)
安装MITM Proxy运行环境以及MITM Proxy
sudo apt-get install python-pip python-dev libffi-dev libssl-dev libxml2-dev libxslt1-dev #安装必要的运行环境
sudo pip install mitmproxy #安装mitmproxy,安装成功后会在生成两个工具/usr/local/bin/mitmproxy与/usr/local/bin/mitmdump
到这里为mitmproxy的环境安装完毕,接下来进行目标机方面的配置
- CA证书的安装
要捕获https证书,就得解决证书认证的问题,因此需要在通信发生的客户端安装证书,并且设置为受信任的根证书颁布机构。下面介绍6种客户端的安装方法。
当我们初次运行mitmproxy或mitmdump时,
会在当前目录下生成 ~/.mitmproxy文件夹,其中该文件下包含4个文件,这就是我们要的证书了。
mitmproxy-ca.pem 私钥
mitmproxy-ca-cert.pem 非windows平台使用
mitmproxy-ca-cert.p12 windows上使用
mitmproxy-ca-cert.cer 与mitmproxy-ca-cert.pem相同,android上使用
1. Firefox上安装
preferences-Advanced-Encryption-View Certificates-Import (mitmproxy-ca-cert.pem)-trust this CA to identify web sites
2. chrome上安装
设置-高级设置-HTTPS/SSL-管理证书-受信任的根证书颁发机构-导入mitmproxy-ca-cert.pem
2. osx上安装
双击mitmproxy-ca-cert.pem - always trust
3.windows7上安装
双击mitmproxy-ca-cert.p12-next-next-将所有的证书放入下列存储-受信任的根证书发布机构
4.iOS上安装
将mitmproxy-ca-cert.pem发送到iphone邮箱里,通过浏览器访问/邮件附件
6.Android上安装
将mitmproxy-ca-cert.cer 放到sdcard根目录下
选择设置-安全和隐私-从存储设备安装证书
一些额外的资料:
>* 官方教程: http://mitmproxy.org/doc/index.html
>* win7、linux安装使用pip、mitmproxy
>* 推荐给开发人员的6个实用命令行工具
>* 使用mitmproxy进行Android的http抓包
>* mitmproxy 入门案例 -『抱抱』24小时销毁的真相(iOS端)
>* mitmproxy实践教程之调试 Android 上 HTTP流量
MITM Proxy环境搭建的更多相关文章
- Nexus(一)环境搭建
昨天,成功搭建了自己的 Maven 环境(详见:Maven(一)环境搭建),今天就来研究和探讨下 Nexus 的搭建! 使用背景: 安装环境:Windows 10 -64位 JDK版本:1.7 Mav ...
- 攻城狮在路上(陆)-- hadoop分布式环境搭建(HA模式)
一.环境说明: 操作系统:Centos6.5 Linux node1 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 ...
- Ionic- Android 开发环境搭建
Ionic- Android 开发环境搭建 为时一周的IONIC ADNROID 环境终于在各种处理错误中搭建成功,以下记录下搭建过程中遇到的各种情况的处理办法. 一 首先,当然是enviroment ...
- visual studio 2015 + Cordova 开发环境搭建
简单的写一些,备忘,太折腾了,特别是通过代理上网的我们国内的开发者 1.当然是安装Visual Studio 2015,别忘了选择Tools For Apache Cordova. 对于通过Proxy ...
- maven3.2.3+eclipse4.4+JDK1.8+win8.1_64bit环境搭建
--------------------------------------- 博文作者:迦壹 博客标题:win8.1_64bit+eclipse4.4+maven3.2.3+JDK1.8环境搭建 博 ...
- keepalived+nginx高可用负载均衡环境搭建
上篇说道keepalived的环境搭建,本来keepalived结合lvs更有优势,但是也可以结合nginx来使用.下面接着说下nginx的环境搭建 环境信息: nginx(master) 192. ...
- 点我吧工作总结(技术篇) Cobar原理和环境搭建
我思故我在,提问启迪思考! 1.什么是Cobar? Cobar是关系型数据的分布式处理系统,它可以在分布式的环境下看上去像传统数据库一样为您提供海量数据服务.cobar已经在阿里巴巴B2B公司稳定运行 ...
- Android总结篇系列:Android开发环境搭建
工欲善其事必先利其器. 1.安装并配置Java环境进入Java oracle官网,当前网址如下:http://www.oracle.com/technetwork/java/javase/downlo ...
- android开发环境搭建日记和嵌入式Android开发环境初探
非常感谢博客园的各位,按照你们的博文,还有利用百度和谷歌逐渐建立了android的开发环境,只是给自己备份参考查看,看过的人可以忽略这篇文章. 本文章大部分参考了:http://www.cnblogs ...
随机推荐
- CF385C Bear and Prime Numbers
思路: 需要对埃氏筛法的时间复杂度有正确的认识(O(nlog(log(n)))),我都以为肯定超时了,结果能过. 实现: #include <bits/stdc++.h> using na ...
- Sql Server数据库对象访问权限控制
以下内容主要针对database层面的数据访问权限(比如select, insert, update, delete, execute…) 1.直接给user权限GRANT EXECUTE TO [u ...
- codevs 2046 孪生素数 3 (水题日常)
时间限制: 1 s 空间限制: 32000 KB 题目等级 : 黄金 Gold 题目描述 Description 在质数的大家庭中,大小之差不超过2的两个质数称它俩为一对孪生素数,如2和3.3和5 ...
- exportfs - 管理NFS共享文件系统列表
概述 (SYNOPSIS) /usr/sbin/exportfs [-avi] [-o options,..] [client:/path ..] /usr/sbin/exportfs -r [-v] ...
- zabbix设置多个收件人
1.建群组 2.添加群组权限 3.添加用户,归属到上面新建的组 4.动作里发送消息给新建的组 5.这样设置后,管理员账号不用设置收件媒介
- C++ isalpha、isalnum、islower、isupper用法
1. isalpha isalpha()用来判断一个字符是否为字母,如果是字符则返回非零,否则返回零. cout<<isalpha('a'); //返回非零 cout<<isa ...
- 全局/局部变量、宏、const、static、extern
#pragma mark--全局变量和局部变量 根据变量的作用域,变量可以分为: 一.全局变量 1> 定义:在函数外面定义的变量2> 作用域:从定义变量的那一行开始,一直到文件结尾(能被后 ...
- Map容器之热血格斗场
3343:热血格斗场 总时间限制: 1000ms 内存限制: 65536kB 描述 为了迎接08年的奥运会,让大家更加了解各种格斗运动,facer新开了一家热血格斗场.格斗场实行会员制,但是新来的 ...
- XML 解析 & 特殊字符报错
在xml文件中,有一些符号是具有特殊意义的,如果直接使用会导致xml解析报错,为了避免错误,我们需要将特殊的字符使用其对应的转义实体进行操作.这些字符如下 < == < > = ...
- nginx 获取真实ip
使用阿里云SLB,无法获取真实ip问题 官方给出的是如下用法,需要安装模块,大体上是没有错的,但是比较模糊,实际操作中可能会踩坑,所以参考学习即可,不必照搬.(那个http_realip_module ...