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 loopbackauto 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流量

转载于:https://www.cnblogs.com/MarkWoo/p/4788890.html

MITM Proxy环境搭建相关推荐

  1. CentOS6.5_64下 nginx+uwsgi+Python +多站点环境搭建

    本文章为各位介绍一篇关于CentOS6.5_64下 nginx+uwsgi+Python +多站点环境搭建 python web django 框架的例子. 作为一个严谨(其实就是有强迫症)的程序,为 ...

  2. Hadoop完全分布式HA环境搭建

    一.前提准备 实验环境下准备4台虚拟机,必须安装好jdk并配置好环境变量.(点击查看jdk的安装配置) 二.节点规划 NN1 NN2 DN ZK ZKFC JN node1 * * * node2 * ...

  3. 第二期 AOSP 环境搭建、下载和编译 《手机就是开发板》遇到问题解决

    第二期 AOSP 环境搭建.下载和编译 <手机就是开发板>遇到问题 编译通过,庆祝一下: 编译时需要注意事项 清华大学软件镜像站:repo从这里下载 https://mirror.tuna ...

  4. 第七章 前端开发——前端工程化(NPM、脚手架、前端环境搭建)

    第七章 前端工程化(NPM.脚手架.前端环境搭建) 一.支持环境 二.NPM包管理工具 三.Vue生成器 四.前端的集成环境 五.项目目录结构 六.前端Vue框架与后端Django框架的简单交互 一. ...

  5. ngnix之lnmp环境搭建及Dvbbs搭建

    LNMP环境搭建 引导语:前面我们做过LAMP环境的搭建,而对于后起之秀nginx而言,其性能相对apache提高了很多, 故本实验借助于nginx来LNMP环境, 环境搭建分三步:mysql绿色包安 ...

  6. Hadoop 2.x 完全分布式HA集群环境搭建

    Hadoop 2.x 完全分布式HA集群环境搭建 目录 Hadoop 2.0 环境搭建 前提:环境准备 第一步:修改hadoop-env.sh配置文件,配置好JAVA_HOME环境变量 第二步:修改h ...

  7. lnmp环境搭建 php7,lnmp环境搭建(centos6.9+mysql5.7+php7.1+nginx1.10)

    安装前准备:CentOS 6.9 64位 最小化安装 yum install -y make gcc gcc-c++ perl zlib-devel libaio libpng libpng-deve ...

  8. AngularJS2 环境搭建:

    AngularJS2 基础学习: 参考 mybase 3-26 文件 angular 环境的构建:( 由于 Angular 编写的代码不是 浏览器可以直接运行的,需要经过编译,所以需要构建一个环境) ...

  9. linux基本项目环境搭建

    文章目录 linux基本项目环境搭建 java环境搭建 获取java源码包 解压 配置环境变量 使配置文件生效 验证 nginx安装 下载(java也可用此方法下载) 解压 配置(configure) ...

最新文章

  1. debian宝塔界面安装php失败,宝塔面板安装遇到的问题
  2. AdventureWorksBI.msi 和 AdventureWorksDB.msi 的官方下载地址及安装方法
  3. 【Python】 linux中python命令的命令行参数
  4. flink查看operater链的中间结果+SingleOutputStreamOperator的用法
  5. css --- 弹性盒子
  6. exar 带容隔离_带有美白功效的6款隔离霜 美白隔离两不误
  7. android在线root,KingRoot全球率先实现Android 7.0一键 Root
  8. java 页面传值_java-jsp springmvc-controller 传值到页面的方法
  9. 138. 复制带随机指针的链表
  10. Windows系统下的python程序安装
  11. 高性能日记--show profile剖析sql语句
  12. jquery版本安全漏洞问题
  13. Fisher exact test费雪精确检验
  14. FID图像质量评估指标
  15. android接入facebook登陆
  16. 解决windows10环境下conda创建环境出现 No writeable pkgs directories configured
  17. Buffer Cache(缓冲区缓存)篇:keep pool(保留池)
  18. [附源码]Java计算机毕业设计SSM电脑配件仓储后台管理系统
  19. C++ push方法与push_back方法 浅析
  20. mysql必知必会第5版pdf_sql必知必会

热门文章

  1. 拉格朗日(Lagrange)插值算法
  2. chatgpt赋能python:Python绝对值符号:用法及实例
  3. 如何使win10避免自动删除程序文件(疑似病毒),且使该文件能运行
  4. python课件_《python学习课件》.ppt
  5. aix and linux企业技术支持中文译文
  6. 百度云管家吾爱破解论坛会员专用修正安装版
  7. 演示淘宝API调用接口
  8. WebStorm中关于出现windows 找不到文件chrome,请确定文件名是否正确后,再试一次问题的解决方法
  9. 如何用qrcode获取动态二维码?
  10. 关于经济学的几个经典故事