Closed wangyankun17 closed 7 months ago
Sorry for the (huge) delay in responding, but this question is a bit out of scope, and should be probably asked to Stem developers.
I suspect the difference is due to how tor behaves when run with Stem vs. when run with the tor binary that comes with Tor Browser bundle.
During the simple use of geckodriver, I found some confusing places. Specifically, when accessing duckduckgo.com on a separate tab when using a script, I grabbed the corresponding port by analyzing the PID number of tor process, and a number of 9001 ports of different IP addresses were established to connect with the local, which is not in line with the behavior of tor browser. I conducted a control experiment. When I manually click tor browser, only one IP port 9001 will appear to establish contact with the local (even if I visit the tabs of multiple different websites)
This is the code I use: ` import tbselenium.common as cm from tbselenium.tbdriver import TorBrowserDriver from tbselenium.utils import launch_tbb_tor_with_stem
tbb_dir = "/home/xmy/tor-browser-linux64-11.0_en-US/tor-browser_en-US/" tor_process = launch_tbb_tor_with_stem(tbb_path=tbb_dir)
with TorBrowserDriver(tbb_dir, tor_cfg=cm.USE_STEM) as driver:
with TorBrowserDriver(executable_path="/usr/bin/geckodriver") as driver: driver.load_url("https://duckduckgo.com")
driver.load_url("https://check.torproject.org")
tor_process.kill() ` This is the port that appears when analyzing the corresponding PID number of the browser: You can see that the local IP: 192.168.183.131 is connected to 185.117.82.71:9001 and 76.31.229.76:9001 respectively
root@xmy:/home/xmy/webfp/tor-browser-selenium# netstat -nap |grep 15293 tcp 0 0 127.0.0.1:9250 0.0.0.0: LISTEN 15293/tor
tcp 0 0 127.0.0.1:9251 0.0.0.0: LISTEN 15293/tor
tcp 0 0 192.168.183.131:34154 154.35.175.225:443 ESTABLISHED 15293/tor
tcp 0 1 192.168.183.131:59756 98.128.172.245:443 SYN_SENT 15293/tor
tcp 0 1 192.168.183.131:51326 51.77.52.216:443 SYN_SENT 15293/tor
tcp 0 1 192.168.183.131:50550 45.129.182.225:443 SYN_SENT 15293/tor
tcp 0 1 192.168.183.131:60004 162.55.190.170:12333 SYN_SENT 15293/tor
tcp 0 1 192.168.183.131:60764 82.223.202.214:9001 SYN_SENT 15293/tor
tcp 0 0 192.168.183.131:44658 176.31.229.76:9001 ESTABLISHED 15293/tor
tcp 0 1 192.168.183.131:42352 85.204.121.219:9001 SYN_SENT 15293/tor
tcp 0 0 192.168.183.131:41212 185.117.82.71:9001 ESTABLISHED 15293/tor
tcp 0 1 192.168.183.131:33360 144.76.241.182:9001 SYN_SENT 15293/tor
tcp 0 1 192.168.183.131:36948 185.21.217.33:10043 SYN_SENT 15293/tor
tcp 0 0 192.168.183.131:41220 82.103.140.87:443 ESTABLISHED 15293/tor
tcp 0 1 192.168.183.131:55042 193.106.166.105:29001 SYN_SENT 15293/tor I want to know why this happens, because I need a fixed port number to use tcpdump to capture browser exit traffic. Thank you very much for your patience and help!