如何在一个没有root权限的Android设备上创建一个SOCKS代理(英文转载)

news/2024/7/4 19:20:11
How to Setup a SOCKS Proxy for Android Without Root

原网址:http://www.devineloper.com/2013/08/28/setup-socks-proxy-android-without-root/

As the number of mobile Internet-connected devices continues to rise, so does the number of public-WiFi access points. “WiFi” window stickers are all over the place, advertising a “bonus” reason to stop by your local coffee shop, bookstore or Home Depot. While this may make multi-task shopping easier, it also exposes your activities to anyone else on the public network. All browsing data is broadcast to everyone on the public network who wants to see what you’re up to. 

To remedy this, you can create an encrypted SSH tunnel to a computer at home. The tunnel encrypts all of your web browsing data and sends it home first. The home computer then completes the browsing request and forwards the results back through the encrypted tunnel to your mobile device. This gives you the same security you’d have if browsing from your couch at home. This post explains how to setup a SOCKS proxy for an Android device without root.

翻译:了解到这些后,你可以创建一个加密通道链接到你家里的电脑。这个通道加密了你的所有网络请求数据并且发送首先发送到家里的电脑上。然后,你的家用电脑完成网络请求并且通过那个加密通道把结果返回到手机上。这就给了同你在家上网一样的安全性。本文讲解一下如何在一个没有root的Android设备上安装一个防火墙安全会话转换协议代理。

NOTE: There are better solutions for rooted Android devices, but this article assumes you don’t want to root your device. You can also use this article as a guideline to setup non-Android devices with similar software. After a long search for a non-root encrypted proxy solution, I found articles onmichaelchelen.net and calgarytech.blogspot.com that allowed me to do and write the below.

What you’ll need:

  • A Linux server or desktop that you can connect to remotely using SSH
  • An Android phone or tablet

Step 1: If you have a dynamic IP address for the Linux machine, first setup dynamic DNS so you can always get back to your server. Otherwise, you’ll need to write down your IP address every time you leave the house. Here’s an old Wired article that still seems relevant, though the recommended DynDNS.com is no longer very “Free”.
Edit: DynDNS has axed their free service completely.

Step 2: On your [Android] device, download and install ConnectBot and Firefox.

Step 3: Open ConnectBot and generate a public/private key pair. You’ll use the keys to login to your server without having to enter a password every time. To generate a key pair, hit menu and select “Manage Pubkeys”. Then hit menu again and select “Generate”. You’ll be prompted to setup your key details. The settings are up to you. If you set a password for your key pair, you’ll be prompted to enter it to unlock the key the first time you want to connect to your server. Hit “Generate” when you’re done with your settings to generate your key. You’ll be prompted with a blue box to help randomize the key. Just move your finger in a random manner in the blue box until it starts to generate your keys. Once complete, you’ll see the nickname you gave your key, along with a red lock icon.
ConnectBot Keypair Creation Options

Step 4: In ConnectBot->Manage Pubkeys, long press on the key you generated in step 3 until a menu appears, then select “Copy public key” to copy the public key to memory. You’ll paste this onto your SSH server in step 6 to avoid having to enter a password. You can also optionally unlock your key here by tapping the red icon and entering your password. If you don’t, you’ll have to enter it the first time you try to connect to your server using your key.
ConnectBot copy public key screenshot

Step 5: Create a connection to your Linux server using ConnectBot. Just enter your username@yourURL:port in the box at the bottom of the main screen and hit the enter key. Enter the password for your username when prompted and hit the enter key again to complete the connection.

Step 6: (Optional) Copy your public key to your Linux server to avoid having to enter your password in the future. After you connect in step 4, enter the following, making sure to paste the public key you copied in step 3 by hitting Menu and “Paste” (Keep the quotes shown below):

echo "YouPublicKey" >> .ssh/authorized_keys

ConnectBot Save Public Key to SSH server screenshot
After you copy your key, type exit or hit menu and select “Disconnect”. Then try to connect again. You shouldn’t be prompted for a password.

Step 7: Hit Menu and select “Port Forwards”. Then hit Menu again and select “Add port forward”.

  • Nickname: Anything you want
  • Type: Dynamic (SOCKS)
  • Source port: 8080 (Make sure you enter a port. The default is greyed out and just a placeholder. If you don’t enter a port, your Port Forward will disappear and you’ll be left scratching your head as to why)
  • Tap “Create port forward” and make sure you see your new port forward listed. If not, double-check that you entered a port.

ConnectBot Port Forwarding setup screenshot

ConnectBot Port Forward Success Screenshot

Step 8: Configure Firefox to use your newly created SSH tunnel. Open Firefox and type “about:config” in the address bar. Search for and set the following values:

  • network.proxy.socks: 127.0.0.1
  • network.proxy.socks_port: 8080 (or whatever port you chose in step 7)
  • network.proxy.socks_remote_dns: true
  • network.proxy.type: 1 (this tells Firefox to use your manual proxy settings)

Firefox Proxy Options 1 ScreenshotFirefox Proxy Options 2 Screenshot

Step 9: Done! There are a couple of things you can do to check if your proxy is working.

  1. Check your IP address
    • When connected to a WiFi or mobile network that’s different from your Linux server’s network, google “what’s my ip” in Firefox and note your IP address.
    • Open another browser (one that you haven’t set up to use the proxy) and do the same. The IP address in Firefox should match the IP address of your Linux server, while the IP address in the other browser should be your device’s external IP. The two IP addresses should not match.
  2. Close the SSH tunnel and try to browse the Internet
    • Open ConnectBot and disconnect the SSH tunnel by typing exit in the shell and hitting the enter key, or by tapping menu and selecting “Disconnect”.
    • Open Firefox and attempt to browse the internet. You should see a proxy refused connection error.

Firefox Proxy Refused Connection error screenshot

Once you verify your new SOCKS proxy is working, you can be confident that your nosy fellow shoppers can’t see where you’re browsing. Unless, of course, they’re standing over your shoulder.

image


http://www.niftyadmin.cn/n/3649492.html

相关文章

用自己的手机调试Android应用程序——Android Studio

最近在学习Android应用开发,一般来说都是用AVD建立的虚拟手机来调试和运行Android应用程序。不过自己的手机也是Android的,所以就是尝试用自己的手机来调试程序。不过在调试之前先做好手机的重要数据备份,因为有时候可能自己写的程序有BUG或者…

Angular-cli卸载以后安装指定版本

由于我的J2EE前端使用的是Angular 8.3.18。而Angular默认安装的是9.0以上的版本。这样在项目启动的时候会一直提示Angular版本不匹配。而且9.0的有些时候不太稳定。所以就想卸载重新安装指定版本。以下操作在CMD窗口运行。 卸载 1、卸载之前的版本 npm uninstall -g angular/cl…

Android开发必备的国内外网站、博客、论坛

Android现在是一个非常流行的移动操作系统。这个小小机器人创建一个大大的世界。许多开发商也致力于Android开发。对于新手和专家,你都要保持你技术储备的更新,知道在Android社区中的最新头条。所以我们推荐一些值得开发人员收藏的Android相关的网站&…

如何在Ubuntu 18.04上使用Ansible自动化初始服务器设置

介绍 (Introduction) Server automation now plays an essential role in systems administration, due to the disposable nature of modern application environments. Configuration management tools such as Ansible are typically used to streamline the process of aut…

[C#]服务为何会依赖于WMI Performance Adapter服务

[C#]服务为何会依赖于WMI Performance Adapter服务编写者日期关键词郑昀ultrapower2005-6-13Service C# Cache “WMI Performance Adapter”“Microsoft Enterprise Library”我们的C#编写的Windows Service“CommandListener”在Windows 2000上运行正常,但是在Wind…

android中常用的开源项目

在android开发过程中为了提高开发的效率,我们常需要引用一些第三方jar或者是使用之前项目的一些源码,这里我罗列一些较好的开源资源,方便使用。 1.menudrawer A slide-out menu implementation, which allows users to navigate between view…

什么是SWOT分析?怎样进行SWOT分析?

SWOT 模型含义介绍 优劣势分析主要是着眼于企业自身的实力及其与竞争对手的比较 , 而机会和威胁分析将注意力放在外部环境的变化及对企业的可能影响 上 。在分析时,应把所有的内部因素(即优劣势)集中在一起,然后用外部的力量来对这些因素进行…