how to send traffic from mitmproxy to another proxy server - proxy

I have a need to redirect mitmproxy to another proxy server. Let say an example.
Browser -> mitmproxy -> fiddler
Browser proxy was set to 8089
mitmproxy is running on 8089
fiddler listening on 8090
now how can i do proxy forward mitmproxy using -F
i tried mitmproxy -p 8089 -F localhost:8090, but the output was unrecognised argument -F
Any help ?
Thanks

You can specify an upstream proxy using -U (which was previously called -F).

-U is deprecated now. You shall use --mode upstream:SPEC
mitmproxy --mode upstream:http://<target-proxy-ip>:<target-proxy-port> --upstream-auth <target-proxy-user-name>:<target-proxy-password> -p 3128 --set block_global=false
Reference: https://docs.mitmproxy.org/stable/concepts-modes/#upstream-proxy
Example (allows outside connection):
Server-1 (ip: x.x.x.x)
mitmproxy --proxyauth "user1:pass1" -p 3128 --set block_global=false
Server-2 (ip: y.y.y.y)
mitmproxy --mode upstream:http://x.x.x.x:3128 --upstream-auth user1:pass1 -p 3128 --set block_global=false
Client
Proxy: y.y.y.y:3128

Related

Start a https without port number using npm http-server on Mac

I am using npm http-server to start a https server with:
http-server --ssl --cert ~/.localhost-ssl/localhost.crt --key ~/.localhost-ssl/localhost.key
It defaults to 8080 port. So I can use https://192.168.22.123:8080 to access. But I wanted to not have to specify 8080 at all, for ex: https://192.168.22.123. Can it be done?
According to http-server there is a -p or --port option. But not sure if or how to do it?
Edited: It seemed like I can redirect to any ports other than well known ports. For example, I have no problem with 8081 or 4000. But if I specified 80, it gave me an error: events.js with Unhandled 'error' and Error: listen EACCES 127.0.0.1:80. I did see other posts that people were using 80.
Any suggestions why mine is not working?

How to make mitmproxy to intercept all traffic from all ports using a reverse proxy?

I have 3 machines:
1. An application which uses different databases and other services.
2. Proxy (mitmproxy) (192.168.56.51)
3. Server with all databases and services which are required for the application. (192.168.56.50)
All 3 machines are in the same local network running Centos 7.
Right now machine 1 is using databases and services on machine 3.
My task to use the machine 2 as it would be a machine 3 and show all the traffic. I.e. I need to be able to listen to all ports on machine 2 and redirect traffic on equivalent ports on machine 3.
I made port redirects to mitmproxy port (8080) on machine 2 in iptables:
-A PREROUTING -i eth0 -p tcp -m multiport --dports 23:8079 -j REDIRECT --to-ports 8080
-A PREROUTING -i eth0 -p tcp -m multiport --dports 8081:65000 -j REDIRECT --to-ports 8080
Also, added forwarding to machine 2:
/etc/sysctl.d/mitmproxy.conf :
net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1
net.ipv4.conf.all.send_redirects=0
Then I started mitmproxy on machine 2:
mitmproxy --rawtcp
Then I tried to run an application, but mitmproxy shows a warning when something is trying to connect to a database. An example:
Warn: 192.168.56.1:51204: HTTP protocol error in client request: Bad HTTP request line: b'\x04\x00\x00\x00\x01...
What am I doing wrong?

Using pfctl to redirect traffic does not work

I am trying to set up a proxy on OSX to intercept traffic. I found that the native way to do it is using pfctl and using a transparent proxy tool like mitmproxy or Burp Suite. Mitmproxy has a chapter in their docs about how to set up the Mac with pfctl and for Burp Suite you can find this instruction. However, none of these are showing traffic in mitmproxy or burp.
My /etc/pf.conf
scrub-anchor "com.apple/*"
nat-anchor "com.apple/*"
rdr-anchor "com.apple/*"
rdr-anchor "forwarding"
dummynet-anchor "com.apple/*"
anchor "com.apple/*"
load anchor "com.apple" from "/etc/pf.anchors/com.apple"
load anchor "forwarding" from "/etc/pf.anchors/forwarding"
and my /etc/pf.anchors/forwarding (en0 is my working wifi adapter)
rdr log (all) on en0 inet proto tcp to any port 80 -> 127.0.0.1 port 8080
rdr log (all) on en0 inet proto tcp to any port 443 -> 127.0.0.1 port 8080
I am also setting
▶ sudo sysctl -w net.inet.ip.forwarding=1
▶ sudo sysctl -w net.inet6.ip6.forwarding=1
and these commands work without throwing an error
▶ sudo pfctl -vnf /etc/pf.conf
▶ sudo pfctl -evf /etc/pf.conf
Here is another related question, but as I am on Sierra, the answer does not apply to me.

Squid Transparent + HTTPS

I enable Squid transparent in windows using this method (youtube link). But after enabled, pages with HTTPS is showing error.
In Chrome this message is: SSL Connection Error (ERR_SSL_PROTOCOL_ERROR)
In Firefox: Security Connection Fail (Error code: ssl_error_rx_record_too_long)
IE: Check if TLS and SSL Protocols has enabled.
Is possible disable the SSL / HTTPS in squid?
Or solve this problem in another way.
Tks.
Yes, I didn't watch the video clip - but simply tell your browser to not use the proxy for HTTPS or port 443.
Alternately, if you're using the transparent firewall method, you can either tell the firewall to skip port 443, or to ONLY redirect port 80 through the proxy eg.
iptables -t nat -I PREROUTING -p tcp --dport 443 -j ACCEPT
the above will just accept HTTPS-port traffic and ignore all the other firewall rules for it
or
iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to 3128
which will only redirect port 80 to your transparent squid.
PS It's a really bad idea to try and proxy SSL - it completely defeats the purpose of SSL.
According to this link: http://wiki.squid-cache.org/KnowledgeBase/Windows
Squid features not operational:
DISKD: still needs to be ported
Transparent Proxy: missing Windows non commercial interception driver
SMP support: Windows equivalent of UDS sockets has not been implemented
So it might not be possible to use squid as transparent proxy on window.

How to set proxy for JMeter from behind another proxy?

I'm new to jmeter.
I'm trying to test a web app using proxy server.
I have gone through the jmeter docs and got the settings but I'm currently working under company proxy.
So how can I set the proxy server for jmeter from behind the current proxy?
Read :
https://jmeter.apache.org/usermanual/get-started.html#proxy_server
If you are testing from behind a firewall/proxy server, you may need to provide JMeter with the firewall/proxy server hostname and port number.
To do so, run the jmeter.bat/jmeter file from a command line with the following parameters:
- '-H' [proxy server hostname or ip address]
- '-P' [proxy server port]
- '-N' [nonproxy hosts] (e.g. *.apache.org|localhost)
- '-u' [username for proxy authentication - if required]
- '-a' [password for proxy authentication - if required]
Example :
jmeter -H my.proxy.server -P 8000 -u username -a password -N localhost
Alternatively, you can use --proxyHost, --proxyPort, --username, and --password
If you're looking to learn jmeter correctly, this book will help you.
Change Port and Proxy on JMeter 5.0
used the Proxy and the Port below Just as example , it was origenal answer for this question - Cannot capture jmeter traffic in fiddler
UI Mode
Create Thread Group --> HTTP Request
Go to Advanced fill "Server Name or IP:" = 127.0.0.1 , "Port Number:" = 8888
Non UI MODE
Add to your command -H 127.0.0.1 for Proxy Host
-P 8888 for Proxy port
Example:
C:\jmeter5.0\bin>jmeter -n -t C:\example.jmx -l C:\scriptresults.jtl -H 127.0.0.1 -P 8888

Resources