termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.24k stars 3.04k forks source link

Package request: PowerShell Core #1729

Open christianrondeau opened 7 years ago

christianrondeau commented 7 years ago

This will sadly depend on #516 but once done, should allow for pretty cool stuff like remote connection on Windows machines without Cygwin.

https://github.com/PowerShell/PowerShell/blob/master/docs/building/linux.md

I thought I'd create the package request anyway, at least to raise interest in the .Net Core package request, since I clearly don't have enough time to fill the knowledge gap required to be actually helpful :)

SDRausty commented 6 years ago

It looks like powershells are currently available in Termux through Arch Linux PRoot. This script is designed to install Arch Linux in just a few keystrokes. Tapping this link https://sdrausty.github.io/TermuxArch/setupTermuxArch.sh will transfer setupTermuxArch.sh to your device. Simply run bash ~/storage/downloads/setupTermuxArch.sh to install Arch Linux in Termux.

screenshot_20171130-004712

To add Archstrike and Blackarch distributions that provide the powershells follow these steps. Use https://sdrausty.github.io/TermuxArch/ to install, update and configure Arch Linux on device first.

Edit your /etc/pacman.conf by adding:

[archstrike] Server = https://mirror.archstrike.org/$arch/$repo

[blackarch] Server = http://blackarch.org/blackarch/$repo/os/$arch

Next run pacman -Syu to update your repository listing. Then to install either distribution, run one of these commands:

pacman -S archstrike --needed pacman -S blackarch --needed

:: There are 663 members in group archstrike: ~2G download (~6G on device) :: There are 1602 members in group blackarch: ~5G download (~16G on device)

That's a lot of pentesting. If you don't desire this much pentesting, don't install everything.

To search only for powershells use pacman -Ss powershell. To install use pacman -S powershellname.

Enjoy 😀

christianrondeau commented 6 years ago

@sdrausty that sounds too good to be true. Is it too good to be true? Does that also means .NET Core itself runs in this? I will definitely look into this as soon as I can! I'll report back here!

christianrondeau commented 6 years ago

@sdrausty even though running arch linux on Termux is definitely pretty cool, there's no powershell builds; only powershell exploits! (and. NET Core either, which makes sense). Unless I missed something.

SDRausty commented 6 years ago

@christianrondeau thank you for your time and diagnostics. Evidently, what you are looking for is not present it seems. What do you think about all those exploits? This is surprising news.

christianrondeau commented 6 years ago

@sdrausty it is indeed impressive, though I'm not into hacking that much. The goal of this package request is using powershell as a shell on termux, and allow remote connections (legit) on windows machines.

kuttor commented 6 years ago

Ah man.... Was hopeful and then BLAM nothing.... I am a senior DevOps engineer that works for a major cloud company that using VMWare on the backend, so some Windows boxes... I am already utilizing Samsung Dex with Termux to do a lot of my coding, development and the one thing that would be cool would be to get PowerShell and then PowerCLI. (I rarely jump into it anyways since most of my work is all *nix) but it would really make Samsung Dex a very viable OS and also it would be great to rub it in the faces of my Windows engineer counterparts. :P

SteveL-MSFT commented 5 years ago

PowerShell does work in https://github.com/CypherpunkArmory/UserLAnd

christianrondeau commented 5 years ago

@SteveL-MSFT that sounds great, though I couldn't get it to work due to /proc/stat being unavailable on Android : https://github.com/PowerShell/PowerShell/issues/10290

This conversation should probably shouldn't be in this repo, but I invite you to comment on the linked issue if you used a working method that I'm unaware of.

Thanks for sharing!

jrdnr commented 5 years ago

I was able to get pwsh 7 v5 running following https://dev.to/thementor/i-run-powershell-on-android-and-so-can-you-458k Screenshot_20191024-205434

trying to get it running in Termux now but missing something

SteveL-MSFT commented 5 years ago

@jrdnr can you provide more details of what issue you are hitting? the /proc/stat issue was fixed awhile back

jrdnr commented 5 years ago

Unfortunately my Linux foo is pretty week. Running Arch from the UserLAnd app, I was able to get 7 preview 5 going no problem. But trying to get it running in Termux on a Pixel 3a in I can't figure out what is missing. When I try to run it I get the "bash: pwsh file does not exist" error.

I tried to use ldd to find if it was missing stuff and it listed a 4 or 5 libSomething.o files. That about where I ran out of ideas

TylerLeonhardt commented 5 years ago

Idk why I'm getting what I'm getting...

Steps:

> wget https://github.com/PowerShell/PowerShell/releases/download/v7.0.0-preview.5/powershell-7.0.0-preview.5-linux-arm64.tar.gz
> tar -xvzf powershell-7.0.0-preview.5-linux-arm64.tar.gz
> ./pwsh
bash: ./pwsh: No such file or directory

But it's there:

> ls -l pwsh
-rwx------ 1 u0_a115 u0_a115 135944 Oct 18 17:05 pwsh

I installed strace and tried it:

strace ./pwsh

execve("./pwsh", ["./pwsh"], 0x7fe34c6090 /* 15 vars */) = -1 ENOENT (No such file or directory) strace: exec: No such file or directory +++ exited with 1 +++

Even tried the absolute path and that yielded the same result.

I installed file and ran that:

file ./pwsh

./pwsh: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=81c4cf86329191d3b6daf4e8356fd7718c582a98, stripped

And it should be the right PowerShell because:

> uname -m
aarch64
jrdnr commented 5 years ago

That's the same thing I ran into, my research appears to indicate it had something to do with missing "libraries" required to execute.

I then tried $ ldd pwsh And got

libpthread.so.0
libdl.so.2
libstdc++.so.6
libm.so.6
libgcc_s.so.1
libc.so.6
ld-linux-aarch64.so.1

But now I'm way out of my depth, runs great on Arch Linux using UserLand ¯_( ͡° ͜ʖ ͡°)_/¯ IDK

SteveL-MSFT commented 5 years ago

Are those libs all there?

Grimler91 commented 5 years ago

@TylerLeonhardt @jrdnr It is not possible to use programs that have been compiled for a "normal" linux distro in termux. pwsh has been linked against the gnu libc (glibc), which is not compatible with android's libc (bionic) that all packages in termux have been linked against. It works fine in chroot since those system do not use android's libc. Only way to make pwsh work in termux is to compile the sources and target android/termux.

See also https://wiki.termux.com/wiki/Differences_from_Linux

SteveL-MSFT commented 5 years ago

May have to wait until .NET Core supports Android before pwsh will work successfully. A number of .NET Core CLR issues for Android still active

HunterInTheZone commented 3 years ago

run PowerShell on Android (UserLAnd) https://dev.to/thementor/i-run-powershell-on-android-and-so-can-you-458k

FinecoFinit commented 3 years ago

Any news?

stale[bot] commented 2 years ago

This issue/PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

xtkoba commented 2 years ago

Package requests should not be tagged as wontfix by Stale bot.

sharunkumar commented 2 years ago

May have to wait until .NET Core supports Android before pwsh will work successfully. A number of .NET Core CLR issues for Android still active

seems like the issues with "android" filter have all been closed 🤔

chaoscreater commented 2 years ago

On Android, you can take the curL binrary file and install it (need root on Android). Once that's done, you can run curL natively in Android (via either Termux, Android Terminal or even via a shell script invoked from Tasker or MacroDroid).

Is it possible to do the same thing with Powershell Core? Like, is there a single binary file that we can run natively in Android? Or must it absolutely be run in a proper Linux environment?

Without using UserLand (which is just an emulated Linux VM), is it possible to install Linux within Termux and then install Powershell there? I'm not sure whether running Linux in Termux is the same as running a VM or not though.

The reason why I would like to do this in Termux is because there's a Termux plugin for Tasker (and MacroDroid) and this means you can actually automate cool things on your phone. For example, if XYZ happens then trigger a script to be run in Termux.

babaric-dev commented 2 years ago

Any update here?

rc-chuah commented 1 year ago

Any Updates On PowerShell For Termux?

iti-D commented 8 months ago

any news regarding this?

sylirre commented 8 months ago

Pull requests are welcome to complete this

TomJo2000 commented 8 months ago

The blocker here is getting a dotnet runtime compiled and working in Termux/Android. I think there was some stuff happening on that front a couple months ago, but I don't think anything useful to us ever came of it.