RegawMOD adb shell su privileges issue - c#

I'm currently building a c# windows app that has a requirement of emptying out the sms inbox from an android devices.
I'm using RegawMOD.android lib to create and execute adb commands.
The first thought was to delete mmssms.db and reboot the device which works.
However, rebooting the device takes a lot of time.
so I took another approach :
I copied the DB to the internal SD card
pulled it to my pc
accessed it with sqlite (through code) and emptied the SMS table.
copied it back to internal SD card.
The problem is with copying it back to /data/data/com.android.providers.telephony/databases/
When I try to run it inside the code, I get permission denied even though I run it with shell and su settings. If I run the same code in adb shell on a command line prompt, it works perfectly.
this is the code :
AdbCommand MoveToData = Adb.FormAdbShellCommand(device, true, "cat", "/storage/sdcard0/download/mmssms.db > /data/data/com.android.providers.telephony/databases/mmssms.db");

In your su 0 cat /storage/sdcard0/download/mmssms.db > /data/data/com.android.providers.telephony/databases/mmssms.db command only the part before the redirection runs with root privileges. The redirection is still being run with your app's user ID.

Related

Autorun console application in linux

I have developed a console application using MVS and I compiled it so can run on linux.
It runs on linux when I manually run and everything works so far. But whenever I try to run it at boot using crontab it seems not to be working.
My application is a HttpListener. The linux environment I run this is a robot's. I've not used linux very much so I have found and used the below commands to get this run at boot.
#reboot /home/rauman/Downloads/webserver
Then I tried setting a delay of 20secs,
#reboot sleep 20 && /home/rauman/Downloads/webserver
I normally run this application with terminal like below and works fine
./webserver
I'm accessing the robot using putty
After adding this to run at boot, I could see the pid of the application,
pidof webserver
So I guess it runs, but got no permission or something?
I have given permission for the file using,
chmod +x webserver
Any help is appreciated.
Edit : Solved
As, Mr. R pointed out
#reboot sleep 20 && cd /home/rauman/Downloads/ && /.webserver
I ran into the same problem a few days ago. My app runs flawlessly when I call it from its working directory but it failed when getting called from outside. It turned out the app reads a file by a relative address. So I had to change either the program or the pwd.
The easiest way that I came by is changing pwd:
#reboot sleep 20 && cd /home/rauman/Downloads/ && ./webserver
crontab runs processes as root, so any another file (such configurations) beloning to your user profile folder cannot be accessibile by ¢rotab.
Is this you scenario?
If yes, you should them into /etc or into /root.

Open Network And Sharing Center programatically without explorer.exe

Is there a way of opening this from a C# application without needing explorer.exe to be running? I have a Windows 10 IoT device running with a custom shell, but needs to be able allow the user to set up WiFi connections.
I have tried this:
ProcessStartInfo psInfo = new ProcessStartInfo("control.exe", "/name Microsoft.NetworkAndSharingCenter");
However while this works fine when running normally in Windows, when I run it in the custom shell (explorer.exe is not running), nothing happens.
This differs from the Network Connections applet which runs fine even within the custom shell...
ProcessStartInfo psInfo = new ProcessStartInfo("rundll32.exe", "shell32.dll,Control_RunDLL ncpa.cpl");
Is there a way to get rundll32 to run the "Network and Sharing center"? I can't find another .cpl that does it and any research on the 'net just points me back to the original command I tried above.

Powershell script only running in ISE

Running a script that starts and kills/cleans two jobs via batch file before I package it for an EXE, works great in ISE elevated but immediately fails in console or command prompt with the following:
The code I have put together is here: https://pastebin.com/FWaZD249
I tested it with:
PS1 to EXE, get the same results
Non-elevated ISE same results
Elevated console same results
Elevated CMD same results
Elevated ISE works (only after saving?)
It's really close to being done, basically, it's just a little script that checks the 5900 port for established connections, updates a form of a list of connections, and sends a little notification if someone new has connected, it runs on our print server computer which is screen-shared remotely via TightVNC, so operators don't get surprised when their mouse starts moving on them.
cmd batch code looks like this
powershell.exe -NoExit ". C:\Users\VS-Print-Server\Desktop\Userchecker.PS1"
As I mentioned in the comment: you initialize the jobs $job1 and job2 with $FormLib respectively $LisLib before those variables are set/initialized. Moving line 1 through 30 (everything before Write-Verbose -Verbose 'Before:') to the very end should make it work.

TF.exe and TfSecurity.exe authentication on AzureDevOps

I have a piece of legacy c# code (console application) that runs as a nightly batch and fires off TF.exe and TFSSecurity.exe commands at AzureDevOps.
The commands are built by the c# code and then executed by means of launching PowerShell and executing them.
All have worked fine until now, but lately, it started failing for tf30063 authentication errors.
TF30063: You are not authorized to access https://dev.azure.com/
As part of my troubleshooting I have picked a few of these commands that are being built and executed them in an interactive PowerShell session.
tf permission /recursive $/<tfs_project_name>/ /collection:https://dev.azure.com/<organization_name>/
TFSSecurity /imx adm: /collection:https://dev.azure.com/<organization_name>/
It produces the same result - TF30063: You are not authorized to access https://dev.azure.com/.
The logged-on user (where the commands are run) is able to access this AzureDevOps URL via a browser.
Digging a bit deeper I ran the command: tf settings connections help which returned the following output:
Server Url : https://<organization_name>.visualstudio.com/
User :
I was actually expecting the passed URL here: https://dev.azure.com/
Not sure how this URL got there, or how to get it out - but, be that as it may, the empty user field arouses some suspicion.
I am really trying to figure out what the authentication flow/procedure is when executing these commands (TF and TFSSecurity) in Powershell.
I have been prompted for authentication by an AzureDevOps dialog once, but where do these provided credentials stored? And for how long?
I have been snooping around the Windows credentials in the Credential Manager, here I found some bits and pieces - but nothing conclusive.
Question:
Does anybody perhaps know how these 2 applications (tf.exe and TfSecurity.exe) handles authentication and storing of credentials?
System specs:
OS: Windows Server 2016
Powershell Version: 5.1.14393.3053
Location (version) of the tf.exe and TfSecurity.exe
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\
Team Explorer>
The cached credentials that tf.exe referenced might get corrupted. We donot know what caused this issue, nor can we give a certain method to fix this. You have to try below possible solutions to narrow down the fix.
1,
Using the browser from within your Visual Studio, View->Other Windows->Web Browser and navigate to the https://dev.azure.com/. Then check if it is logged in the wrong account, log out and relog in if wrong account is logged in.
2,
Running the following command from the Developer Command Prompt for VS:
tf workspaces /collection:https://dev.azure.com/<organization_name>
3,
Go to Team Explorer > Manage Connections (Little Plug next to Home button) > Right Clicked on Project > Connect. Then reenter in your credentials.
4, To clear all the caches
Close all Visual Studio instances, delete %LOCALAPPDATA%.IdentityService as you did.
Clear TFS caches %LOCALAPPDATA%\Microsoft\Team Foundation\7.0\Cache
Clear all the browser caches especially for the stored password
5, Run Visual Studio as another user:
cd C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE
runas /netonly /user: devenv.exe
Enter the user possword, then Team Explorer > Manage Connections
If none of the obove method fixes this issue. Please check here and here for more possible solutions.
You can also report a problem to Micrsoft Develop community(Report a problem > Azure Devops) if above issue persist.
For Server Url : https://.visualstudio.com/. It is the old version dev.azure.com domain name. The official document says it can be used as usual.
Update:
TF30063 error for TFSSecurity
The cached credentials for TFSSecurity is stored in the registry. You can delete it.
HKEY_CURRENT_USER\Software\Microsoft\VSCommon\14.0\ClientServices\TokenStorage\VisualStudio\VssApp
After you deleted the cached credentials in above registry. It will prompt you to re-enter the credential when you run tfssecurity.exe command again.

Solaris not returning output for certain commands over remote session using Renci.SshNet

I am using a .NET library Renci.SshNet to connect to remote Solaris machine (its a VM on ESXi). It connects fine.
I use the following method to execute the commands and get the Standard Output. This works fine on any Linux machine and almost all command on Solaris (Except few - which is where the issue is)
outstring = sshClient.RunCommand(command).Execute();
For example when command = "cat /etc/release | grep Solaris" -it works fine.
However, when command = "smbios -t SMB_TYPE_SYSTEM" - it doesn't return anything. I try redirecting it to a file. The file gets created - but doesn't have anything on it.
I connect to the system using PuTTY and run the command - it runs perfectly and gives the desired output.
I am perplexed by this behavior. I am using a username with root privilloginto logon. So privileges are ruled out (anyway the same user gets the output in PuTTY).
I am wondering if there is any setting or restriction on Solaris (I am running ver 11.3) which does not allow the smbios command to run like this over a remote connection? Or it is something else? Any guidance will be extremely helpful. If any further info is required, please let me know.
Well, it turns out that it was to do with Path settings. When you login through Putty the $PATH as defined gets set. Hence smbios runs from Putty.
But in a SSH session the $PATH environment variable does not get applied. So its not able to find smbios to run. If you give the full path of smbios - like /usr/sbin/smbios it executes fine over Renci.SshNet.

Categories