Running exe file behind a txt file - windows

Was reading about ADS(Alternate data streams) in windows, so came across this thing.
Working on Windows XP to test the following.
I created a file with name - sample.txt with the content - "hello there"
Created another file with name - second.txt with content - "I am hidden"
At command prompt did the following:-
type second.txt > sample.txt:newfile.txt
It executes successfully
Now, if i type this:-
notepad sample.txt:newfile.txt
Notepad opens newfile.txt with the content - "I am hidden"
Till here, its normal
Now, I tried to hide an exe file,lets say - notepad.exe behind a txt sample like this:--
(i have copied notepad.exe in the same folder)
type notepad.exe > sample.txt:newexe.exe
Above command runs successfully.
Question is, now how can i run that exe file which is now behind text file. My guess is I need some form of interpreter (like notepad.exe in the first example) to make my exe run. Does exe files require some sort of interpreter to run(like text files need some editor)??
I know, exe files can be run directly, but here in this case thats not working. Even tried:--
start second.txt:newexe.exe
but it doesnt work. Help will be greatly appreciated, as I dont know much about windows internals.

Sensibly, Windows will not allow this and will throw an Access Denied if you try to execute it, similarly there is no easy way to copy a binary stream.
With administrative privs you can mklink blah.exe sample.txt:newexe.exe which would create a symlink to the executable ADS, executable via blah.exe.

Under Windows XP you must give the full qualified name of the ADS to start (in this case I have 'hidden' depends.exe in dbgview.exe):

Related

7zip SFX not extracting files

I'm trying to create a SFX file and run a vbs afterwards.
Here's my config file:
;!#Install#!UTF-8!
InstallPath="c:\\windows\\temp\\"
ExecuteFile="cscript.exe"
ExecuteParameters="c:\\windows\\temp\\script.vbs"
;!#InstallEnd#!
The .7z archive is not corrupt, I cn=an open and extract files.
here's how I created the .exe:
copy /b 7zS.sfx + config.txt + SylinkReplacer.7z SylinkReplacer.exe
When I run it a cmd windows flashes I have the feeling it's trying tu run the vbs but I can see it has not been extracted in C:\windows\temp.
I ran process monitor and apparently it extract the files in my users' %appdata% within a temporary folder named 7zNNNNNN which gets deleted afterwards.
Any suggestion? Thanks
I found a way to make it work (I actually found it on stackoverflow but now I can't find it anymore).
;!#Install#!UTF-8!
ExecuteFile="ReplaceSylink.vbs"
;!#InstallEnd#!
This is not the best solution since I wanted it to run it with cscript (console) while on many servers the default engine is wscript (GUI).
I'll use something to force cscript like this on this one http://www.robvanderwoude.com/vbstech_engine_force.php

Is there a way to run a command line "inside" a symlink?

I have a symlink named example.avi that points to a real example.avi video file. When a program tries opens the symlink, it really opens the video file. But now I would like execute a command line whenever a program tries to open the symlink file.
Is that possible?
ps: windows
No, there is no built-in way of creating a symlink or other file system object that causes a command to be executed when it is opened by an application.
It should in principle be possible to do this with a file system filter driver. But that's very complicated. I believe there are some third-party tools to simplify this sort of task, but I don't have any experience with them.
While I am clearly ignorant on the subject of symlinks in Windows (see my comments on your question). I just played with it and proved that you could basically do this by symlinking to a wrapper for your avi. I.e. symlink to an exe or a batch file, etc. which does what you want and then opens the avi. Here's a test I ran with txt files and notepad:
Create a file called test.txt with some text. Create a file next to it called test.bat. Here's the batch:
notepad test.txt
When you run the batch, it just opens the txt in notepad.
Then I added a symlink:
mklink test2.txt test.bat
Now, when I type test2.txt in the command prompt, or double click on it, it runs the batch and opens the test.txt file. Obviously, you can use the same basic logic. It doesn't, however, fire the batch off when I open the symlink in Notepad++. It just opens to batch for editing instead.
Of course, maybe you don't want a second file, in which case you need to literally embed your avi in some wrapper. I guess we ned to know more about what you want to do. It sounds like an attempt at malware hidden in a video to me...

Batch file to rar and password (very specific)

I was trying to make a batch file that compresses a specific folder (using winrar) to a specific location (not the same as the folder location), password (that I can choose myself) protects it AND does all of that without a cmd screen popping up.
I have very little knowledge of programming and managed to get some things working, but not all at the same time and in the same batch file.
Also to rar that file do I need Winrar to be installed on the computer or can I reffer to the rar.exe (copied from the Program Files Windows folder to a different location)?
AFAIK it's not possible to run a a bat file without a visible CMD window without using any additional tools. Here's a link to a post how to run a hidden console: https://superuser.com/questions/62525/run-a-batch-file-in-a-completely-hidden-way
It is possible to use just the rar.exe but I would use 7zip instead. The performance is way better, it's also portable and you have many options in the command line. So your project would contain the bat file itself, the vb script file and the 7z.exe (or rar.exe). If you want, you can even create a single .exe file out of these three by creating a SFX file: http://www.7zsfx.info/en/
Hope I could help you.

vb6 read and write a text file in win 7

I am trying to execute a .exe file (created by VB6) on Windows 7.
What the application will do is to simply create a text file, and then read the text for a text file.
All the functions are being tested successfully on Windows XP. When I execute the .exe file on Win 7, the functions act as usual but the file I created doesn't exist on the specific path (C:\test.txt). The most weird thing is that I can still read the content from the text file (through the .exe file) despite being unable to find the text file on file explorer.
Then I discovered that I have to choose [run as Administrator] to execute the .exe file, so that the file (test.txt) will be created on the C: drive. I am very curious how the .exe file can still read the text file even it is not existed, and how can I force the .exe file to run as Administrator?
Here is the coding to write and read a file.
Open "C:\" & "test.txt" For Output As #1
Print #1, cDrive.Text
Close #1
Open "C:\" & "test.txt" For Input As #1
Input #1, msg
Close #1
cDrive.Text = msg
Exit Sub
To answer the third remark:
Windows Vista and Windows 7 User Access Control (UAC) introduced a feature called the VirtualStore which is designed to add an extra layer of security protection for applications installed under the Program Files folder. If you search for the file on you hdd you might find a second instance of the file in /User/AppData/Local/VirtualStore
So that's why it is still able to read text.txt allthough is doesn't excist in the location you mentioned.
I suggest that you run the program as an administrator by using the feature in the shortcut (after compiling and installing).
If you asked about it when in debug mode - I believe that if the user that you use to debug is an admin - it's enough.
I have no answer for your question "I am very curious how the .exe file can still read the text file even it is not existed"
You should not specify open as #1 directly, use FreeFile() function instead Look here for a sample.
Good luck
Drive C is being protected by Win7, you can still write to it, but you really shouldn't.
If you want to run the app as admin:
right click on the EXE
select PROPERTIES
go into COMPATABILITY tab
check RUN THIS PROGRAM AS ADMINISTRATOR check box
click OK
Now every time you run the app, it will run as administrator

What is the simplest program I can write to invoke a batch script?

It is very stupid that windows will not let you add batch files to your quick launch or whatever they call in in windows 7. That bar across the bar, i can attach firefox there, command prompt, even paint (my favorite), but not a batch file. I can "pin" it to another program, which is just weird. I want it to standalone, the batch file does enough work by itself.
So lets say i have batch file. What is the simplest executable program I can write to invoke said script. Then I can finally pin all my useful batch files on that quick-jump-pin-bar.
If I remember right, you can do this by first pinning a shortcut to CMD.exe to the taskbar. Then edit the command, and change CMD.exe to CMD.exe /c MyBatchFile.bat. I believe this will execute the batch file.
Since you can only pin one cmd, here's an alternative, assuming you have the .NET framework installed - a very simple C# application:
Populate a textfile with the following contents:
class Program {
static void Main() {
System.Diagnostics.Process.Start(#"c:\test.bat");
}
}
where Program is the name of the executable you want to create, and c:\test.bat is the full path to the batch file. Save the file as Program.cs. Execute the following from the command line:
c:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe Program.cs
You can replace 2.0.50727 with whatever directory exists on your machine - might be 1.1.something or 3.5 or 4.0.something - it's all the same for this scenario.
This will generate Program.exe. You can put that exe file wherever you want, and pin that executable to the taskbar. You can discard the .cs file once you're done making your executables.
Kind of a crappy solution, but it should work, assuming you don't find anything better. And if you don't have the .NET framework (which I'm not sure is even possible in Windows 7), you can install it pretty easily.
The easiest way is to create a folder, put your batch files in it, and pin the folder to the menu bar :D
You can also write a startup script, so the batch file will be executed on startup, but I don't know if you want to run those scripts on every bootup... You can also add the command prompt to the bar, and edit the startup path..
Use command switches on CMD.exe.
cmd.exe /c "myscript.bat"
As a sort of workaround you could use the following trick. Pin an arbitrary application to the task bar, Shift+right click on the pinned icon, select Properties, change 'Target' and 'Start in' accordingly. Rename it too if you like.
You can pin more than one .bat file using this technique.

Resources