jpillora / chisel

A fast TCP/UDP tunnel over HTTP
MIT License
12.66k stars 1.33k forks source link

How to use in Android? #86

Open simonho234 opened 5 years ago

jpillora commented 5 years ago

An Android app developer would need to develop an app using chisel

On Wed, 13 Mar 2019 at 18:25, simonho234 notifications@github.com wrote:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jpillora/chisel/issues/86, or mute the thread https://github.com/notifications/unsubscribe-auth/AAmr8xCES0bzheCeG4FOLbLwXr3GAwWVks5vWKflgaJpZM4bsj3f .

Meteorite commented 5 years ago

You can take chisel binary for android arm from here. Copy it to your device, e.g.:

adb push chisel_android_arm /data/local/tmp

Then, make it executable there and run as a commandline utility like in any other OS (using adb, if android device is connected to your desktop or laptop, or with the help of terminal emulator app, if it is not).

Of course, to make it more comfortable, you'll need a wrapper android app with appropriate UI.

berkant commented 4 years ago

@Meteorite Do you know any way to use chisel as VPN, to make all traffic flow through it?

ingnelson commented 4 years ago

How about using Terminal app like TERMUX on Android ?? Can you explain how to do it ??

ingnelson commented 4 years ago

You can take chisel binary for android arm from here. Copy it to your device, e.g.:

adb push chisel_android_arm /data/local/tmp

Then, make it executable there and run as a commandline utility like in any other OS (using adb, if android device is connected to your desktop or laptop, or with the help of terminal emulator app, if it is not).

Of course, to make it more comfortable, you'll need a wrapper android app with appropriate UI.

@Meteorite can you create a mini tutorial or the commands line to use Chisel on Android , maybe using the Terminal Termux app , please. https://play.google.com/store/apps/details?id=com.termux

Do you have a telegram account I can contact you ?.

berkant commented 4 years ago

@ingnelson That should work as long as you have the terminal. Either compile it yourself for ARM or download precompiled executables from releases page. Then cd in terminal to where executable is and run it.

Meteorite commented 4 years ago

@Meteorite Do you know any way to use chisel as VPN, to make all traffic flow through it?

@0xbkt On rooted device you can use ProxyDroid, like I do (it is not a VPN, just traffic redirection via iptables). On non rooted device you can try smth, that intercepts traffic with the help of VpnService like this (I have not tried it though).

ingnelson commented 4 years ago

@Meteorite Meteorite can you give me the commands to try it on Android using the Terminal Termux , please. I am not a programmer , I hope.you help me.

kawaiiDango commented 4 years ago

I forked a recent fork of socksdroid and added chisel client support https://github.com/kawaiiDango/chiselsocksdroid (download link in readme). The apk size is large because it contains 4 copies of chisel, one for for each architecture.

ingnelson commented 4 years ago

@kawaiiDango I just try the chisel app for Android and works very very well ! This app work better than a VPN . Thanks very much. This app it is great . I just sent to you a email with 2 questions . My email: ingnelson86@gmail.com Or send me a telegram message at : https://t.me/Trader_Nelson I am trying to contact you. I hope your answer.

kawaiiDango commented 4 years ago

I wonder whom you mailed to, since I didn't receive any and I dont have a publicly visible email address on my profile. Create an issue on my repo if this is related to the app and we will discuss there.

ingnelson commented 4 years ago

@kawaiiDango look that GitHub do not let create an issue on your repo maybe because it is a for of a fork , and if I try to create a request it send me to sockdroid repo so I create it there . https://github.com/ycmmonkey/socksdroid/pull/1 I don't know if it was correct create it there . I will wait your answer.

kawaiiDango commented 4 years ago

That is an unmerged pull request. I tried with --header "Foo: Bar" and it just gave the help text. The current version of chisel doesn't support headers except the host header through --host but I don't see a common use case for that, so I didn't implement a UI for it

ingnelson commented 4 years ago

@kawaiiDango if the app has "http header" option I can add a "host" header that is not block by the firewall and the firewall think I am visiting the websites allowed . By the way if the app has a "server name indication" (SNI) option , I can add a host that the firewall allowed me to visit to bypass it, otherwise the firewall block me because it doesn't recognize the "server URL" from Chisel. IMG_20200424_091759

ezbik commented 3 years ago

It works perfectly even on a non-rooted android in Termux. Absolutely no issues. I used chisel_arm64 binary on Xiaomi A2lite. EDIT: For me it was enough get its embedded socks server working. About tunneling all the apps through Chisel client - no idea.

vincentDcmps commented 3 years ago

@Meteorite Hello how do you use chisel with proxy droid?

It's working with chiselsocks proxy but with this solution I don't use local dns on my network despite I have create a remote port in chisel client on local dns so I would test another solution

excelsi commented 2 years ago

I tried to run chisel_arm64 binary in termux on my android but it did't recognize it. I copied over the extracted binary (from chisel_1.7.7_linux_arm64.gz) to the $home directory of termux and tried to run it. It didn't recognize the command also after a "chmod +777" on the file. Any help? Thanks!

Update: Do i need to build (with go build) with the source files again on my anroid? I tried that but it said that the go.mod file is missing here.

I wonder if maybe the file names are wrong here because he added somehow a _ infront...

Screenshot_20220717-173420

vetch101 commented 2 years ago

I tried to run chisel_arm64 binary in termux on my android but it did't recognize it. I copied over the extracted binary (from chisel_1.7.7_linux_arm64.gz) to the $home directory of termux and tried to run it. It didn't recognize the command also after a "chmod +777" on the file. Any help? Thanks!

Update: Do i need to build (with go build) with the source files again on my anroid? I tried that but it said that the go.mod file is missing here.

I wonder if maybe the file names are wrong here because he added somehow a _ infront...

(https://user-images.githubusercontent.com/8747559/179405712-06b7d9ac-b5c0-440f-807a-a4e55f273f81.png)

I had a similar issue. I was able to get it running on my android by downloading the Android NDK and using that to help go cross-compile to android.

excelsi commented 2 years ago

Thats nice .. do you have a little guidance for a non android Developer? 😉 Thanks!

vincentDcmps commented 2 years ago

Hello,

I don't know if this can help but on my Android I have used https://github.com/kawaiiDango/chiselsocksdroid

vetch101 commented 2 years ago

Thats nice .. do you have a little guidance for a non android Developer? 😉 Thanks!

Honestly, I wouldn't claim to be a developer, let alone an android one, but, I believe this is how I did it running on an Ubuntu box, so the various package names may be different on a different OS... You may also need Android Studio, which I installed around the same time, but I don't believe so,

sudo apt install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386 sudo apt install clang-format clang-tidy clang-tools clang clangd libc++-dev libc++1 libc++abi-dev libc++abi1 libclang-dev libclang1 liblldb-dev libllvm-ocaml-dev libomp-dev libomp5 lld lldb llvm-dev llvm-runtime llvm python3-clang sudo apt install google-android-ndk-installer cd go/src/github.com/jpillora/chisel/ CGO_ENABLED=1 GOOS=android GOARCH=arm64 CC=/usr/lib/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang go build .

Good luck...

(Having said that, as @vincentDcmps suggests, it may be easier to use something prebuilt like chiselsocksdroid).

excelsi commented 2 years ago

@vetch101 Thanks, will try!

excelsi commented 2 years ago

The build seems sucessfull but the chisel file that comes out still wasn't recognized as command in termux...maybe a hard computer science problem D: ... Or i missed something important here..

vetch101 commented 2 years ago

Sorry to hear that; if you want to try it, here's the version that I built which is working on Termux my phone...

https://drive.google.com/file/d/1C3EmYhrhnMvFhnL9ENWNEMMdXwi0fU3d/view

excelsi commented 2 years ago

Thanks bur in termux i hit a hard wall any way i try...will try chiselsocksdroid maybe also

vetch101 commented 2 years ago

Fair enough; good luck

excelsi commented 2 years ago

Solved my problem now with the required commands and syntax 😉

chmod +x chisel and ./chisel to call

vetch101 commented 2 years ago

Ah yeah; makes sense.

Glad it's working for you now.

essoojay commented 1 year ago

i got server running with,

chisel server -p 4449 --socks5 --auth xxx:yyy

but couldnt get chiselsocksdroid to work // Ama complete noob. can anyone help to get android app running.

thanks all

0xE232FE commented 1 year ago

Compile chisel with ENV GOOS=android GOARCH=arm or GOARCH=arm64

If you have Root Permission

Just copy the Binary to your phone and give executable permission. chmod +x chisel

else NO Root Permission

Install Termux from F-Droid (!!!! NOT !!!!! FROM GOOGLE PLAY STORE because Google hosting very old Version!)

Copy the Binary to your phone and then move the binary to your Termux Home Directory. You are only allowed to assign executbale Permission in the Termux Directory Structure.

The only Trick is to fix DNS Resolution because Go Applications looking for File /etc/resolv.cfg to resolv Domain Names. With #Fix2 you can map the /etc/resolv.cinf file from $PREFIX/etc/resolv.conf -> /etc/resolv.conf so Go will find the file! :-) The #Fix1 is kind of emulator and might leak performance of your running application.

Fix#1 You can use the Application termux-chroot this is kind of emulation and will intercept every system call and would make your Application run slower. But on fast phone CPU it doesn't matter.

Fix#2 You can install PROOT and run your command like `proot -b $PREFIX/etc/resolv.conf:/etc/resolv.conf ./chisel client ...`
essoojay commented 1 year ago

Compile chisel with ENV

GOOS=android

GOARCH=arm or GOARCH=arm64

If you have Root Permission

Just copy the Binary to your phone and give executable permission. chmod +x chisel

else NO Root Permission

Install Termux from F-Droid (!!!! NOT !!!!! FROM GOOGLE PLAY STORE because Google hosting very old Version!)

Copy the Binary to your phone and then move the binary to your Termux Home Directory. You are only allowed to assign executbale Permission in the Termux Directory Structure.

The only Trick is to fix DNS Resolution because Go Applications looking for File /etc/resolv.cfg to resolv Domain Names. With #Fix2 you can map the /etc/resolv.cinf file from $PREFIX/etc/resolv.conf -> /etc/resolv.conf so Go will find the file! :-) The #Fix1 is kind of emulator and might leak performance of your running application.

Fix#1 You can use the Application termux-chroot this is kind of emulation and will intercept every system call and would make your Application run slower. But on fast phone CPU it doesn't matter.

Fix#2 You can install PROOT and run your command like `proot -b $PREFIX/etc/resolv.conf:/etc/resolv.conf ./chisel client ...`

Thank you for your response, I appreciate. I ran the proot command and fix2 threw up this error:

can't sanitize binding "/data/data/com.termux/files/usr/etc/resolv.conf": No such file or directory

Am a complete noob, hopefully you can help here too

Thank you

MasterKia commented 1 year ago

The ultimate solution to run Chisel on Android using Termux (thanks to @essoojay)

Download the ARM64 version of Chisel for GNU/Linux and make it executable. Enter: nano $PREFIX/etc/resolv.conf

File content should be: nameserver 1.1.1.1

Then save the file and use: proot -b $PREFIX/etc/resolv.conf:/etc/resolv.conf ./chisel client ...

MasterKia commented 1 year ago

https://github.com/termux/termux-packages/pull/9721#issuecomment-1365777412:

The fix in this PR does not apply to pre-built binaries or build for other platform than Android. We won't fix for these cases.