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 ...
随机推荐
- ES6学习笔记(5)----数值的扩展
参考书<ECMAScript 6入门>http://es6.ruanyifeng.com/ 数值的扩展 1.Number对象的扩展(1)javascript的全局函数isNaN,isFin ...
- java.lang.NoSuchMethodError: org.hibernate.cfg.Environment.verifyProperties
我在使用jpa2+spring4+hibernate4 的时候,报错java.lang.NoSuchMethodError: org.hibernate.cfg.Environment.verifyP ...
- XSS漏洞扫描经验分享
关于XSS漏洞扫描,现成的工具有不少,例如paros.Acunetix等等,最近一个项目用扫描工具没有扫出漏洞,但还是被合作方找出了几个漏洞.对方找出的漏洞位置是一些通过javascript.ajax ...
- Struts2 前端与后台之间传值问题
老是被前端与后台之间的传值给弄糊涂了,特此写一篇blog进行总结. 一. 前端向后台传值 (1)属性驱动 属性驱动是指在Action类里,包含表单里对应的字段(字段名称一样),同时设置对应的gette ...
- 最新精品 强势来袭 XP,32/64位Win7,32/64位Win8,32/64位Win10系统【国庆版版】
本系统是10月最新完整版本的Windows10 安装版镜像,Win10正式版,更新了重要补丁,提升应用加载速度,微软和百度今天宣布达成合作,百度成为Win10 Edge浏览器中国默认主页和搜索引擎,系 ...
- js函数中获得当前被点击元素
问题描述:在html页面中点击<a>或者’按钮‘,进入js中的函数,在js函数中获得被点击那个<a>或‘按钮’元素 解决方法:方法一: html中: <a>标签:& ...
- 油猴 tamperMonkey 在百度首页 添加自己的自定义链接
发现 GM_addStyle 函数不能用了,从写加载css函数. 剩下找个定位 添加内容 就很简单了. // ==UserScript== // @name helloWorld // @namesp ...
- caffe layer注册机制
Caffe内部维护一个注册表用于查找特定Layer对应的工厂函数(Layer Factory的设计用到了设计模式里的工厂模式).Layer_factory的主要作用是负责Layer的注册,已经注册完事 ...
- Mac 安装Fiddler 抓包工具
官方安装文档https://www.telerik.com/download/fiddler/fiddler-osx-beta 如果输入mono Fiddler.exe报下面这个错误 WARNING: ...
- [POJ] 2223 Muddy Fields
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11490 Accepted: 4270 Description Rain has ...