RDP to call an EXE file, not the whole desktop - remote-access

I have used this code to implement RDP.
This works fine but now I want to implement a system , that will call a particular EXE file from the server. Not the whole desktop.
Any idea how can I implement this?
Process rdcProcess = new Process();
rdcProcess.StartInfo.FileName = Environment.ExpandEnvironmentVariables(#"%SystemRoot%\system32\cmdkey.exe");
rdcProcess.StartInfo.Arguments = "/generic:TERMSRV/192.168.0.16 /user:" +Saltlake1" + " /pass:" + "saltlake#1234";
rdcProcess.Start();
rdcProcess.StartInfo.FileName = Environment.ExpandEnvironmentVariables(#"%SystemRoot%\system32\mstsc.exe");
rdcProcess.StartInfo.Arguments = "/v " + "192.168.0.16";
rdcProcess.Start();

Related

Is there any way to configure emulator in Android Studio?

I am doing a project about Android forensics where I need to dump data from android devices so I am using emulator from android studio. using android version 8.1.0. I am following a repo from github here's the link;https://github.com/mspreitz/ADEL
In order to dump file the prerequisite is to add configuration in the xml folder sub directory named https://github.com/mspreitz/ADEL/blob/master/xml/phone_configs.xml
But I cant find any way to configure the emulator...
if anyone could enlighten me will appreciate a lot I have successfully ran the scripts but unable to dump database.the scripts runs ..the code to run '' python adel.py -d emulator-5554'''. I have tried it already but the problem here is the script is unable to dump database for instance: calendar data, contacts data, call logs though I have created these databases and stored it on the emulator when the scripts run it shows
" Calendar database doesn't exist"
" Contacts database doesn't exist"
" database doesn't exist" " mms/sms database doesn't exist"
The code for dumping the contacts database is given :
if float(os_version) < 2.0:
contactsdb_name = "contacts.db"
else:
contactsdb_name = "contacts2.db"
try:
contactsdb = subprocess.Popen(['adb', 'pull', '/data/data/com.android.providers.contacts/databases/' + contactsdb_name, backup_dir], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
contactsdb.wait()
_adel_log.log(contactsdb_name + " -> " +
contactsdb.communicate(0)[1].split("(")[1].split(
")")[0] + " -> " + hashlib.sha256(backup_dir +
"/contacts2.db").hexdigest(), 3)
hash_value.write(contactsdb_name + " -> " + hashlib.sha256(
backup_dir + "/" + contactsdb_name).hexdigest() + " \n")
except:
_adel_log.log( "dumpDBs: ----> contacts
database doesn't exist!", 2)
https://github.com/mspreitz/ADEL/blob/master/_dumpFiles.py this is the link of the full script.
If you config the device as
<phone device="emulator" model="sdk" os_version="8">
<smartphone_information>
...
</phone>
you should be able to use the emulator.
Otherwise post the specific error you are receiving.

not allowing me to copy file do to files permission

I have made a program that changes the background picture of my desktop every user defined seconds and there is no problems with that part. However I do have a problem with changing the picture of the log in screen I have set up my computer correctly (a windows 7 computer) to change the background picture (including editing the registry to be able to change the picture more then once).
I currently changing my login picture manually by moving the picture to a folder I created C:\windows\system32\oobe\info\backgrounds. I've chosen to make the task automated using python. I will delete the existing image, copy the new image to the folder and then rename the image to backgroundDefault.jpg and repeat every user defined seconds.
To copy, rename, and delete these files using the os module I've tested these steps in my cmd and it works.
Now what seems to be the problem?
Well I'm able to find the folder using os.path.exists however I'm unable to copy, delete or rename anything because the program doesn't have permission.
It is also worth noting that I have already tried to give my user permission to write in the folder and I already tried to give the python programme administrator access not only the python program but Py.exe and th pyw.exe that sit in the wondows folder
Is there a way to give the program permission or is there another way of changing the folder that I need to move the files to? Or even is there a different snipit of script I could use to achieve a login background change?
def path_writer_bg():
folders_path_bg = input("Please type the folders path of the login background here, then press enter"
"\n>")
if os.path.exists(folders_path_bg):
open("your_path_bg.txt", "w").write(folders_path_bg)
read_folder_path_bg = open("your_path_bg.txt", "r").read()
if os.path.exists("task_bg.txt"):
open("task_bg.txt", "w").write("dir " + read_folder_path_bg + " /s /b >listed_bg.txt")
file_read_task_bg = open("task_bg.txt", "r").readline()
else:
open("task_bg.txt", "w").write("dir " + read_folder_path_bg + " /s /b >listed_bg.txt")
file_read_task_bg = open("task_bg.txt", "r").readline()
os.popen(file_read_task_bg)
else:
input("invalid input. press enter to retry \n")
path_writer_bg()
if os.path.exists("your_path_bg.txt"):
read_folder_path_e_bg = open("your_path_bg.txt", "r").read()
open("task_bg.txt", "w").write("dir " + read_folder_path_e_bg + " /s /b >listed_bg.txt")
file_read_task_e_bg = open("task_bg.txt", "r").readline()
os.popen(file_read_task_e_bg)
else:
path_writer_bg()
def everything_bg():
with open("listed_bg.txt") as file_bg:
num_lines_bg = sum(1 for line_bg in open("listed_bg.txt"))
for num_bg, line_bg in enumerate(file_bg, 1):
rand_line_bg = random.randrange(num_lines_bg - 1)
lines_bg = open("listed_bg.txt", "r").readlines()
open('temp_bg.txt', 'w').writelines(lines_bg[rand_line_bg])
wallpaper_bg()
def wallpaper_bg():
path_bg = open("temp_bg.txt", "r").readline()
if os.path.exists("C:\\Windows\\System32\\oobe\\info\\backgrounds\\backgroundDefault.jpg"):
os.popen("del C:\\Windows\\System32\\oobe\\info\\backgrounds\\backgroundDefault.jpg")
else:
pass
if os.popen("copy /y" + path_bg + " C:\\Windows\\System32\\oobe\\info\\backgrounds"):
os.popen("dir C:\\Windows\\System32\\oobe\\info\\backgrounds /s /b >renamer.txt")
else:
pass
if os.path.exists("renamer.txt"):
rename = open("renamer.txt", "r").readline()
else:
pass
os.popen("rename " + rename + "backgroundDefault.jpg")
wallpaper_bg()
exit()
time.sleep(10)
everything()
Maybe it is because that specific file can't be changed with python due to Microsoft not allowing software to change any file in system32.

DateTime bug between local machine and remote server - using JodaTime(java 1.8)

I have some code running fine locally but i am getting an error when i run it remotely.
I am unable to debug remotely obviously - but from the error I know it has to with some DateTime Logic (belongs to my code).
I am looking for a comprehensive way to find what's different between my machine and this remote server - and that could affect DateTime logic.
I know Locale - 1/ is there a way to know what is affected by Locale?
2/ Any other local settings that could be different between a local machine and a server?
Thanks
I looked at the FirstDayOfWeek and MinimaldaysinFirstWeek
when I run the following code:
Calendar c1 = new GregorianCalendar();
System.out.println(Locale.getDefault() + ": " + c1.getFirstDayOfWeek() + " " + c1.getMinimalDaysInFirstWeek());
Locale.setDefault(Locale.getDefault());
Calendar c = new GregorianCalendar();
System.out.println(Locale.getDefault() + ": " + c.getFirstDayOfWeek() + " " + c.getMinimalDaysInFirstWeek());
I got the following output.... It makes no sense...
en_US: 2 4
en_US: 1 1

Why is File.separator using the wrong character?

I'm trying to add functionality to a large piece of code and am having a strange problem with File Separators. When reading a file in the following code works on my PC, but fails when on a Linux server. When on PC I pass this and it works:
fileName = "C:\\Test\\Test.txt";
But when on a server I pass this and get "File Not Found" because the BufferedReader/FileReader statement below swaps "/" for "\":
fileName = "/opt/Test/Test.txt";
System.out.println("fileName: "+fileName);
reader = new BufferedReader(new FileReader(new File(fileName)));
Produces this output when run on the LINUX server:
fileName: /opt/Test/Test.txt
File Not Found: java.io.FileNotFoundException: \opt\Test\Test.txt (The system cannot find the path specified)
When I create a simple Test.java file to try and replicate it behaves as expected, so something in the larger code source is causing the BufferedReader/FileReader line to behave as if it's on a PC, not a Linux box. Any ideas what that could be?
I don't see where you used File.separator. Try this instead of hard coding the path separators.
fileName = File.separator + "opt" + File.separator + "Test" + File.separator + "Test.txt";

Getting the last modify date of a directory in ftp

How do i get when a directory was recently modify via ftp using c#
I have tried this, with no luck
FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create(new Uri("ftp://" + ftpAddress + "/" + "public_html" + "/" + this.Url));
ftpRequest.Credentials = new NetworkCredential(FTPUsername, FTPPassword);
ftpRequest.Method = WebRequestMethods.Ftp.GetDateTimestamp;
DateTime FtpFileLastModified = ((FtpWebResponse)ftpRequest.GetResponse()).LastModified;
return FtpFileLastModified;

Resources