Send command from PC application to Jailbroken iphone - c#

I am making an simple application on PC by C# to send command to jailbroken iphone (exp: open app, get list application installed on iphone..e.t.c..) but I do not know how to send to iphone, searching google but can not find a thing to do this. Anyone know how to send command to iphone please point me out or some documents to learn about this.
Thank you.

in my opinion the best way to go is using SSH, here's the steps
On the Jailbroken device (Skip this steps if you already have an ssh server installed and running)
Download the SSH server from Cydia
Take note of your device's IP address
Default username: root and password: alpine Remember to change that!, also i would recommend creating another user for your app
In your application
Download and install the SSH.NET library from NuGET here
Implement your appropriate methods to connect,disconnect and send commands, se those examples:
using (var client = new SshClient("phoneIp", "phoneUsername", "phonePassword")) {
client.Connect();
//Open the Facebook app and show your profile
client.RunCommand("open fb://profile");
//Alternative method using `uiopen`
client.RunCommand("uiopen fb://profile");
//Read device network info (install network-cmds first)
Console.WriteLine(client.RunCommand("ifconfig"));
//List all apps installed via Cydia
Console.WriteLine(client.RunCommand("dpkg –list"));
//List all apps that are installed from iTunes/Appstore
Console.WriteLine(client.RunCommand("cat /private/var/mobile/Library/Caches/com.apple.mobile.installation.plist"));
client.Disconnect();
}
I haven't tested this code of course, and I have no Jailbroken iOS device, but this should put you on the right path at least!

First you have to create a daemon on your jailbroken iDevice. It will contain a TCP server, which accepts connections from your PC and translates them into your commands. After that commands will be executed by your daemon and you have to write code to process each type of command.

Another one easy solution would be to use Cycript in conjunction with SSH.
If Cycript is installed on the jailbroken phone and a SSH server is running, you could write some scripts and upload it to the phone.
By running them, it would output relevant informations to the standard output.
You would still have to do some very basic reversing stuff to know what you want to to display (i.e. asking the right SpringBoard controller to have the desired information)

Related

Monitoring Outgoing Requests For Images Xamarin [duplicate]

I would like to monitor network traffic of my Android Phone. I was thinking using tcpdump for Android, but I'm not sure if I have to cross-compile for the phone.
Another question is the following, If I want to monitor the trafic data for a certain application, there's any command for doing that?
TCPDUMP is one of my favourite tools for analyzing network, but if you find difficult to cross-compile tcpdump for android, I'd recomend you to use some applications from the market.
These are the applications I was talking about:
Shark: Is small version of wireshark for Android phones). This program will create a *.pcap and you can read the file on PC with wireshark.
Shark Reader : This program allows you to read the *.pcap directly in your Android phone.
Shark app works with rooted devices, so if you want to install it, be sure that you have your device already rooted.
Good luck ;)
If you are doing it from the emulator you can do it like this:
Run emulator -tcpdump emulator.cap -avd my_avd to write all the emulator's traffic to a local file on your PC and then open it in wireshark
There is a similar post that might help HERE
Note: tcpdump requires root privileges, so you'll have to root your phone if not done already. Here's an ARM binary of tcpdump (this works for my Samsung Captivate). If you prefer to build your own binary, instructions are here (yes, you'd likely need to cross compile).
Also, check out Shark For Root (an Android packet capture tool based on tcpdump).
I don't believe tcpdump can monitor traffic by specific process ID. The strace method that Chris Stratton refers to seems like more effort than its worth. It would be simpler to monitor specific IPs and ports used by the target process. If that info isn't known, capture all traffic during a period of process activity and then sift through the resulting pcap with Wireshark.
For Android Phones(Without Root):- you can use this application tPacketCapture this will capture the network trafic for your device when you enable the capture.
See this url for more details about network sniffing without rooting your device.
Once you have the file which is in .pcap format you can use this file and analyze the traffic using any traffic analyzer like Wireshark.
Also see this post for further ideas on Capturing mobile phone traffic on wireshark
The DDMS tool included in the Android SDK includes a tool for monitoring network traffic. It does not provide the kind of detail you get from tcpdump and similar low level tools, but it is still very useful.
Oficial documentation: http://developer.android.com/tools/debugging/ddms.html#network
Preconditions: adb and wireshark are installed on your computer and you have a rooted android device.
Download tcpdump to ~/Downloads
adb push ~/Downloads/tcpdump /sdcard/
adb shell
su root
mv /sdcard/tcpdump /data/local/
cd /data/local/
chmod +x tcpdump
./tcpdump -vv -i any -s 0 -w /sdcard/dump.pcap
Ctrl+C once you've captured enough data.
exit
exit
adb pull /sdcard/dump.pcap ~/Downloads/
Now you can open the pcap file using Wireshark.
As for your question about monitoring specific processes, find the bundle id of your app, let's call it com.android.myapp
ps | grep com.android.myapp
copy the first number you see from the output. Let's call it 1234. If you see no output, you need to start the app. If you still don't see the app via ps try using top.
Download strace to ~/Downloads and put into /data/local using the same way you did for tcpdump above.
cd /data/local
./strace -p 1234 -f -e trace=network -o /sdcard/strace.txt
Now you can look at strace.txt for ip addresses, and filter your wireshark log for those IPs.
You would need to root the phone and cross compile tcpdump or use someone else's already compiled version.
You might find it easier to do these experiments with the emulator, in which case you could do the monitoring from the hosting pc. If you must use a real device, another option would be to put it on a wifi network hanging off of a secondary interface on a linux box running tcpdump.
I don't know off the top of my head how you would go about filtering by a specific process. One suggestion I found in some quick googling is to use strace on the subject process instead of tcpdump on the system.
Without root, you can use debug proxies like Charlesproxy&Co.
Packet Capture is the best tool to track network data on the android.
DOesnot need any root access and easy to read and save the calls based on application.
Check this out
Try this application
https://play.google.com/store/apps/details?id=app.greyshirts.sslcapture
We can view all networking communications .. even SSL encrypted communications.
The common approach is to call "cat /proc/net/netstat" as described here:
Android network stats

Trying to get Hard Drive Serial Number into a SQL Server via UWP app

I'm a relatively new Developer building my first app.
Right now I'm in the process of developing a UWP app and I am needing to get the Hard Drive Serial number from the PC from the Views (OnNavigatedTo), then after a few more fields are filled out, to then save all values to a SQL Server.
What I have discovered up to this point:
Grabbing some values like Hard Drive SN are not so easy with UWP.
I don't seem to have access to Registry HKLM via UWP
I can grab it very easily with PowerShell, and write it to a JSON or XML file. which I plan to do with a Service Account when PC is imaged.
I Don't know where to put the file where the App can see it.
Writing to Sql Server can only be done by creating a webservice and making HTTP / JSON calls via App. (I have this part setup but have not started accessing it via app yet)
So the part I really need help with I guess, is Where to Put JSON/XML file that App will be able to see and read from. Unless of course, someone knows of another way to get Hard Drive SN into a UWP app.
Thanks for Any Help
The recommended way to do this (if you want to go to the Windows Store) is to use a FileOpenPicker and have the user choose the file manually.
If this is for side-loading only (not going to the Windows Store) you can write the file to the user's Documents folder and then the UWP can read it using documentsLibrary capability without any user intervention. You could also use a fullTrust extension to run the PowerShell script and to put the file in the app's data folder. You can check out the Desktop Bridge docs for more info on fullTrust extensions.

Renci.SshNet SshClient All commands are not working

I'm using SshClient from Renci.SshNet and i have noticed that all the commands are not effective on the remote server.
For example, that one works fine :
mySSH.RunCommand( "touch test");
will create a file on the remote server.
but this one won't do anything :
mySSH.RunCommand( "nohup dnx web &");
I searched all over the internet and i'm so disapointed cause nobody talk about that.
Mostly, all commands that are simple like create a file or a folder, but strong commands like executing a script or starting my application (the most important) just simply don't want to do anything.
Thank you in advance.
Can you run this command when you log in over ssh as the same user Ssh.Net is using?

c++/c# app to connect to linux server

I am planning to do an App either in c++/C# (through Visual Studio) in Windows 7.
OK what this app does is it will accept input through studio elements like text box or buttons ..then it should create an command based on input and run these command on the Linux server.
E.g : One simple example is to restart a certain process on a Linux machine
Now to proceed to my problem:
How do I connect my App to Linux machine?
I don't want to install any third party application as i am not allowed to do so.
If possible please list me the different ways i can do this
Well, you can do this. I am already familiar with this scenario. I have several application setup working this way. The only option that will allow you to do this without any 3rd party application is using SSH protocol.
The SSH protocol is the well known and most power full tool of linux sysadmins. You can execute any command over it on a linux box from any part of the world or any piece of shit which can run an SSH client. Ask me on comment if you need more info on this.
EDIT
One example, if you want to restart certain process.. You can pass the command over SSH as below.
ssh user#server_ip '/etc/init.d/httpd restart"
The above will restart the HTTPD(Apache) service.
Some libraries you can use in .NET
http://www.codeproject.com/Articles/11966/sharpSsh-A-Secure-Shell-SSH-library-for-NET
https://sshnet.codeplex.com/
I have not used above libraries in .Net, Instead I have done several things using linux box with python and bash.
if I understand correctly, to solve this you can implemente WebService.
But when you said :
I dont want to install any third party application as i am not allowed
to do so
I'm afraid you can not setup WebService on Linux server ?
Other possibility, use SSH if already install on linux server (some chance that is) and you probably could find a .Net lib to make SSH
This link will help .Net class to execute remotely on Linux over SSH?

Reading PuTTY output with c#

What i want: I want to read the Output of the PuttY Window with C#
What I've got: Our company has several hundreds of servers with at least 2-3 technical users (which are running applications). We got a database of all the users and passwords. So it's basically search, copy and paste to login.
What i want to do: Write a piece of software that does this automatically.
How far i am: Wrote a tool, that reads the logfile of a single PuTTY instance and looks for the password prompt. Determinates target user and server (based on current server and su - [username]). Retrieves the password and sends it via PostMessage to a selected PuTTY.
The Problem or what i want to change:
I want to be able to read the PuTTY output directly from the PuTTY window, because the logfile is kind of unreliable (TAB, ESCAPE, etc which scrambles the output).
I have used UISpy and other tools to get a control, but no luck.
I don't want to use a keylogger mechanism or something like that.
Maybe a hook or something, but have never done that before.
Additonal Info:
Connection is made over a JumpServer, only ssh connections from there to the target servers are allowed.
Direct login with the tech. user is disabled.
The PuTTY window is already opened and used to work on the server.
Writing a whole new Connection Manager is no option. Coworkers are familar with PuTTY and this solution should be some sort of standalone background worker.
Additonal Info 2:
The goal is to write a strict 3rd party software. Not to use other SSH libs, modify PuTTY source or other approaches. The question is: how to read text from the PuTTY window, beside the logfiles.
I don't know why this hasn't been suggested yet, but plink (which is part of the PuTTY suite) is the command-line version of PuTTY, you'll just need to redirect stdin and stdout to get a relatively powerful (as in features, you'll still need to interpret telnet stuff yourself) SSH client.
Have you considered using OCR?
Sketch of solution would be:
1 - Agent runs waiting to notice a Putty Window (either register a callback with OS for new processes or periodically check the list of running processes)
2 - When a putty is noticed, agent takes screenshot and extracts portion of screen occupied by putty. You would need to extract window location, but can be done via OS calls assuming you have a handle from step 1
3 - Pump this image data into tesseract or something, and get text output back. check to see if the password prompt is there
4 - If prompt is there, it sounds like you had the rest done after this (send info needed via PostMessage)
You should take a look at This Link (Putty StdIn / StdOut. Shows how to open putty from a c# app and how to handle Standard In, Out and Error Output to communicate with your putty instance.
If you are using putty as an SSH tool, use http://www.routrek.co.jp/en/product/varaterm/granados.html C# SSH library
If you are using putty as a serial tool use the inbuilt IO classes
Telnet also has C# libraries, none that I can give any knowledgabel input into what is good.
If you can purpose a modified version of putty, you should modify putty sources and including some pipes (or socket) that communicates with your c# application. Like that, your coworker keep the same software.

Categories