Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Add-Type -AssemblyName PresentationFramework
- Add-Type -TypeDefinition @'
- using System;
- using System.Collections.Generic;
- using System.Runtime.InteropServices;
- using System.Text;
- public static class P
- {
- [StructLayout(LayoutKind.Sequential)] struct L { public uint a; public int b; }
- [StructLayout(LayoutKind.Sequential)] struct LA { public L l; public uint a; }
- [StructLayout(LayoutKind.Sequential)] struct TP { public uint n; public LA p; }
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
- struct PE {
- public uint sz, cu, id;
- public IntPtr hp;
- public uint md, th, pp;
- public int cb;
- public uint fl;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string ex;
- }
- [StructLayout(LayoutKind.Sequential)]
- struct MB { public IntPtr ba, aa; public uint ap; public IntPtr rs; public uint st, pr, ty; }
- [StructLayout(LayoutKind.Sequential)]
- struct MI { public IntPtr ba; public uint sz; public IntPtr ep; }
- [DllImport("kernel32.dll")] static extern IntPtr OpenProcess(uint a, bool b, uint c);
- [DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr h);
- [DllImport("kernel32.dll")] static extern IntPtr GetCurrentProcess();
- [DllImport("kernel32.dll")] static extern IntPtr VirtualAllocEx(IntPtr h, IntPtr a, IntPtr s, uint t, uint p);
- [DllImport("kernel32.dll")] static extern bool WriteProcessMemory(IntPtr h, IntPtr a, byte[] b, IntPtr n, out IntPtr w);
- [DllImport("kernel32.dll")] static extern IntPtr VirtualQueryEx(IntPtr h, IntPtr a, out MB m, IntPtr l);
- [DllImport("kernel32.dll")] static extern IntPtr CreateToolhelp32Snapshot(uint f, uint p);
- [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] static extern bool Process32FirstW(IntPtr s, ref PE e);
- [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] static extern bool Process32NextW(IntPtr s, ref PE e);
- [DllImport("kernel32.dll")] static extern bool DuplicateHandle(IntPtr a, IntPtr b, IntPtr c, out IntPtr d, uint e, bool f, uint g);
- [DllImport("kernel32.dll", CharSet = CharSet.Ansi)] static extern IntPtr GetModuleHandleA(string n);
- [DllImport("kernel32.dll", CharSet = CharSet.Ansi)] static extern IntPtr GetProcAddress(IntPtr m, string n);
- [DllImport("ntdll.dll")] static extern int NtReadVirtualMemory(IntPtr h, IntPtr a, byte[] b, IntPtr n, out IntPtr r);
- [DllImport("ntdll.dll")] static extern int NtQueryObject(IntPtr h, uint c, IntPtr i, uint l, IntPtr r);
- [DllImport("ntdll.dll")] static extern int ZwSetIoCompletion(IntPtr h, IntPtr k, IntPtr a, int s, IntPtr i);
- [DllImport("advapi32.dll", CharSet = CharSet.Unicode)] static extern bool OpenProcessToken(IntPtr p, uint a, out IntPtr t);
- [DllImport("advapi32.dll", CharSet = CharSet.Unicode)] static extern bool LookupPrivilegeValueW(string s, string n, out L l);
- [DllImport("advapi32.dll")] static extern bool AdjustTokenPrivileges(IntPtr t, bool d, ref TP n, uint l, IntPtr p, IntPtr r);
- [DllImport("psapi.dll")] static extern bool EnumProcessModulesEx(IntPtr h, [Out] IntPtr[] m, uint c, out uint n, uint f);
- [DllImport("psapi.dll", CharSet = CharSet.Unicode)] static extern uint GetModuleFileNameExW(IntPtr h, IntPtr m, StringBuilder s, uint n);
- [DllImport("psapi.dll")] static extern bool GetModuleInformation(IntPtr h, IntPtr m, out MI i, uint c);
- static void Priv()
- {
- IntPtr t;
- OpenProcessToken(GetCurrentProcess(), 0xF01FF, out t);
- L u;
- LookupPrivilegeValueW(null, "SeDebugPrivilege", out u);
- TP p = new TP();
- p.n = 1;
- p.p.l = u;
- p.p.a = 2;
- AdjustTokenPrivileges(t, false, ref p, (uint)Marshal.SizeOf(typeof(TP)), IntPtr.Zero, IntPtr.Zero);
- CloseHandle(t);
- }
- static uint FindPid(string nm)
- {
- IntPtr s = CreateToolhelp32Snapshot(2, 0);
- PE e = new PE();
- e.sz = (uint)Marshal.SizeOf(typeof(PE));
- uint r = 0;
- if (Process32FirstW(s, ref e))
- do {
- if (e.ex.ToLower() == nm.ToLower()) { r = e.id; break; }
- } while (Process32NextW(s, ref e));
- CloseHandle(s);
- return r;
- }
- static byte[] Rd(IntPtr h, long a, int n)
- {
- byte[] b = new byte[n];
- IntPtr g;
- int st = NtReadVirtualMemory(h, new IntPtr(a), b, new IntPtr(n), out g);
- if (st != 0) return new byte[0];
- return b;
- }
- static void Wr(IntPtr h, long a, byte[] d)
- {
- IntPtr w;
- WriteProcessMemory(h, new IntPtr(a), d, new IntPtr(d.Length), out w);
- }
- static Tuple<long, long> Mod(IntPtr h, string nm)
- {
- uint n;
- EnumProcessModulesEx(h, null, 0, out n, 3);
- IntPtr[] m = new IntPtr[n / (uint)IntPtr.Size];
- EnumProcessModulesEx(h, m, n, out n, 3);
- for (int i = 0; i < m.Length; i++)
- {
- StringBuilder s = new StringBuilder(512);
- GetModuleFileNameExW(h, m[i], s, 512);
- if (s.ToString().ToLower().EndsWith(nm.ToLower()))
- {
- MI mi;
- GetModuleInformation(h, m[i], out mi, (uint)Marshal.SizeOf(typeof(MI)));
- return Tuple.Create(mi.ba.ToInt64(), (long)mi.sz);
- }
- }
- return null;
- }
- static byte[] Snap(IntPtr h, long b, long z)
- {
- byte[] o = new byte[z];
- MB mb;
- int ms = Marshal.SizeOf(typeof(MB));
- long c = b, en = b + z;
- while (c < en)
- {
- if (VirtualQueryEx(h, new IntPtr(c), out mb, new IntPtr(ms)) == IntPtr.Zero) break;
- long rs = mb.ba.ToInt64();
- long re = Math.Min(rs + mb.rs.ToInt64(), en);
- if (mb.st == 0x1000 && (mb.pr & 0x100) == 0 && (mb.pr & 0x01) == 0)
- {
- long lc = rs;
- while (lc < re)
- {
- int n = (int)Math.Min(0x1000000, re - lc);
- byte[] d = Rd(h, lc, n);
- if (d.Length == n) { Array.Copy(d, 0, o, lc - b, n); lc += n; }
- else lc += 0x1000;
- }
- }
- c = re;
- }
- return o;
- }
- static int Fnd(byte[] h, byte[] n, int s, int e)
- {
- int l = Math.Min(e, h.Length) - n.Length;
- for (int i = s; i <= l; i++)
- {
- bool ok = true;
- for (int k = 0; k < n.Length; k++) if (h[i + k] != n[k]) { ok = false; break; }
- if (ok) return i;
- }
- return -1;
- }
- static long Nx(byte[] im, int p)
- {
- for (int i = p; i < Math.Min(p + 0x20, im.Length - 5); i++)
- if (im[i] == 0xE8) return i + 5 + (long)BitConverter.ToInt32(im, i + 1);
- return 0;
- }
- static int Rva(byte[] im)
- {
- byte[] a = Encoding.ASCII.GetBytes("Current identity is %d");
- List<int> hs = new List<int>();
- int p = 0;
- while (true)
- {
- int i = Fnd(im, a, p, im.Length - a.Length - 1);
- if (i < 0) break;
- if (im[i + a.Length] == 0) hs.Add(i);
- p = i + 1;
- }
- Dictionary<long, List<int>> st = new Dictionary<long, List<int>>();
- for (int i = 0; i + 7 <= im.Length; i++)
- {
- if (im[i] < 0x48 || im[i] > 0x4F) continue;
- if (im[i + 1] != 0x8D) continue;
- if ((im[i + 2] & 0xC7) != 0x05) continue;
- long t = i + 7 + (long)BitConverter.ToInt32(im, i + 3);
- if (t < 0) continue;
- if (!st.ContainsKey(t)) st[t] = new List<int>();
- st[t].Add(i);
- }
- Dictionary<long, int> vt = new Dictionary<long, int>();
- foreach (int s in hs)
- {
- List<int> ls;
- if (!st.TryGetValue(s, out ls)) continue;
- foreach (int x in ls)
- {
- long c = Nx(im, x + 7);
- if (c != 0)
- {
- int o; vt.TryGetValue(c, out o);
- vt[c] = o + 1;
- }
- }
- }
- long bt = 0; int bv = -1;
- foreach (KeyValuePair<long, int> kv in vt)
- if (kv.Value > bv) { bv = kv.Value; bt = kv.Key; }
- return (int)bt;
- }
- static byte[] Sc(string m, int l, int r)
- {
- IntPtr p = GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetModuleHandleA");
- byte[] pl = Encoding.UTF8.GetBytes(m);
- List<byte> s = new List<byte>();
- s.AddRange(new byte[] { 0x48, 0x83, 0xEC, 0x28 });
- s.AddRange(new byte[] { 0x33, 0xC9 });
- s.AddRange(new byte[] { 0x48, 0xB8 });
- s.AddRange(BitConverter.GetBytes((ulong)p.ToInt64()));
- s.AddRange(new byte[] { 0xFF, 0xD0 });
- s.AddRange(new byte[] { 0x48, 0x05 });
- s.AddRange(BitConverter.GetBytes((uint)r));
- s.AddRange(new byte[] { 0x49, 0x89, 0xC2 });
- s.AddRange(new byte[] { 0xB9 });
- s.AddRange(BitConverter.GetBytes((uint)l));
- s.AddRange(new byte[] { 0x48, 0x8D, 0x15, 0x08, 0x00, 0x00, 0x00 });
- s.AddRange(new byte[] { 0x41, 0xFF, 0xD2 });
- s.AddRange(new byte[] { 0x48, 0x83, 0xC4, 0x28 });
- s.AddRange(new byte[] { 0xC3 });
- s.AddRange(pl);
- s.Add(0);
- return s.ToArray();
- }
- static IntPtr Io(IntPtr h)
- {
- byte[] ti = new byte[10000];
- IntPtr cp = GetCurrentProcess();
- GCHandle g = GCHandle.Alloc(ti, GCHandleType.Pinned);
- IntPtr pt = g.AddrOfPinnedObject();
- IntPtr r = IntPtr.Zero;
- for (uint c = 4; c < 8192; c += 4)
- {
- IntPtr d;
- if (!DuplicateHandle(h, new IntPtr(c), cp, out d, 0, false, 0x2)) continue;
- if (NtQueryObject(d, 2, pt, 10000, IntPtr.Zero) >= 0)
- {
- ushort ln = BitConverter.ToUInt16(ti, 0);
- ulong np = BitConverter.ToUInt64(ti, 8);
- if (np != 0 && ln >= 2)
- {
- long of = (long)np - pt.ToInt64();
- if (of >= 0 && of <= 10000 - ln &&
- Encoding.Unicode.GetString(ti, (int)of, ln) == "IoCompletion")
- { r = d; break; }
- }
- }
- CloseHandle(d);
- }
- g.Free();
- return r;
- }
- static long Cv(IntPtr h)
- {
- MB mb;
- int ms = Marshal.SizeOf(typeof(MB));
- long a = 0;
- while (true)
- {
- if (VirtualQueryEx(h, new IntPtr(a), out mb, new IntPtr(ms)) == IntPtr.Zero) break;
- long b = mb.ba.ToInt64();
- long s = mb.rs.ToInt64();
- if (mb.st == 0x1000 && mb.pr == 0x04 && s >= 72)
- {
- long o = 0;
- while (o <= s - 72)
- {
- int n = (int)Math.Min(4096, s - o);
- byte[] d = Rd(h, b + o, n);
- if (d.Length == 0) break;
- int r = 0;
- for (int i = 0; i < d.Length; i++)
- {
- if (d[i] == 0) { r++; if (r >= 72) return b + o + i - 71; }
- else r = 0;
- }
- o += 4096;
- }
- }
- long nx = b + s;
- if (nx <= a || nx >= 0x7FFFFFFFFFFF) break;
- a = nx;
- }
- return 0;
- }
- public static void Send(string m, int l)
- {
- Priv();
- uint id = FindPid("RobloxPlayerBeta.exe");
- IntPtr h = OpenProcess(0x1F0FFF, false, id);
- Tuple<long, long> mo = Mod(h, "RobloxPlayerBeta.exe");
- byte[] im = Snap(h, mo.Item1, mo.Item2);
- int r = Rva(im);
- byte[] s = Sc(m, l, r);
- long a = VirtualAllocEx(h, IntPtr.Zero, new IntPtr(s.Length), 0x3000, 0x40).ToInt64();
- Wr(h, a, s);
- IntPtr io = Io(h);
- long cv = Cv(h);
- byte[] tp = new byte[72];
- BitConverter.GetBytes(a).CopyTo(tp, 56);
- Wr(h, cv, tp);
- ZwSetIoCompletion(io, new IntPtr(cv), IntPtr.Zero, 0, IntPtr.Zero);
- CloseHandle(io);
- CloseHandle(h);
- }
- }
- '@ -Language CSharp
- [xml]$x = @'
- <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- Title="Silicon" Height="360" Width="500"
- WindowStyle="None" AllowsTransparency="True" Background="Transparent"
- WindowStartupLocation="CenterScreen" FontFamily="Segoe UI">
- <Window.Resources>
- <Style x:Key="WC" TargetType="Button">
- <Setter Property="Background" Value="Transparent"/>
- <Setter Property="BorderThickness" Value="0"/>
- <Setter Property="Width" Value="46"/>
- <Setter Property="Height" Value="32"/>
- <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="Button">
- <Border x:Name="bg" Background="{TemplateBinding Background}">
- <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
- </Border>
- <ControlTemplate.Triggers>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter TargetName="bg" Property="Background" Value="#1AFFFFFF"/>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <Style x:Key="WCX" TargetType="Button">
- <Setter Property="Background" Value="Transparent"/>
- <Setter Property="BorderThickness" Value="0"/>
- <Setter Property="Width" Value="46"/>
- <Setter Property="Height" Value="32"/>
- <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="Button">
- <Border x:Name="bg" Background="{TemplateBinding Background}">
- <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
- </Border>
- <ControlTemplate.Triggers>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter TargetName="bg" Property="Background" Value="#C42B1C"/>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <Style x:Key="CB" TargetType="ComboBox">
- <Setter Property="Foreground" Value="#FFFFFF"/>
- <Setter Property="Background" Value="#141414"/>
- <Setter Property="BorderBrush" Value="#2E2E2E"/>
- <Setter Property="BorderThickness" Value="1"/>
- <Setter Property="FontSize" Value="13"/>
- <Setter Property="Height" Value="30"/>
- <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="ComboBox">
- <Grid>
- <ToggleButton Focusable="False"
- IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}">
- <ToggleButton.Template>
- <ControlTemplate TargetType="ToggleButton">
- <Border Background="Transparent"/>
- </ControlTemplate>
- </ToggleButton.Template>
- </ToggleButton>
- <Border Background="{TemplateBinding Background}"
- BorderBrush="{TemplateBinding BorderBrush}"
- BorderThickness="{TemplateBinding BorderThickness}"
- CornerRadius="4" IsHitTestVisible="False">
- <Grid>
- <ContentPresenter Margin="10,0,30,0" VerticalAlignment="Center"
- HorizontalAlignment="Left"
- Content="{TemplateBinding SelectionBoxItem}"
- ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"/>
- <Path HorizontalAlignment="Right" VerticalAlignment="Center"
- Margin="0,0,12,0" Data="M 0,0 L 8,0 L 4,5 Z" Fill="#AAAAAA"/>
- </Grid>
- </Border>
- <Popup IsOpen="{TemplateBinding IsDropDownOpen}"
- Placement="Bottom" AllowsTransparency="True"
- Focusable="False" PopupAnimation="Slide">
- <Border Background="#141414" BorderBrush="#2E2E2E"
- BorderThickness="1" CornerRadius="4"
- MinWidth="{TemplateBinding ActualWidth}"
- MaxHeight="{TemplateBinding MaxDropDownHeight}"
- Margin="0,2,0,0">
- <ScrollViewer>
- <ItemsPresenter/>
- </ScrollViewer>
- </Border>
- </Popup>
- </Grid>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <Style x:Key="CBI" TargetType="ComboBoxItem">
- <Setter Property="Foreground" Value="#FFFFFF"/>
- <Setter Property="Background" Value="Transparent"/>
- <Setter Property="FontSize" Value="13"/>
- <Setter Property="Padding" Value="10,6,10,6"/>
- <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="ComboBoxItem">
- <Border x:Name="bi" Background="{TemplateBinding Background}"
- Padding="{TemplateBinding Padding}">
- <ContentPresenter/>
- </Border>
- <ControlTemplate.Triggers>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter TargetName="bi" Property="Background" Value="#242424"/>
- </Trigger>
- <Trigger Property="IsSelected" Value="True">
- <Setter TargetName="bi" Property="Background" Value="#2E2E2E"/>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- </Window.Resources>
- <Border Margin="15" Background="#0A0A0A" BorderBrush="#2A2A2A" BorderThickness="1" CornerRadius="8">
- <Grid>
- <Grid.RowDefinitions>
- <RowDefinition Height="32"/>
- <RowDefinition Height="*"/>
- </Grid.RowDefinitions>
- <Grid Grid.Row="0" Name="TB" Background="Transparent">
- <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top">
- <Button Name="Bn" Style="{StaticResource WC}">
- <Path Data="M 0,5 L 10,5" Stroke="#CCCCCC" StrokeThickness="1" SnapsToDevicePixels="True"/>
- </Button>
- <Button Name="Bc" Style="{StaticResource WCX}">
- <Path Data="M 0,0 L 10,10 M 10,0 L 0,10" Stroke="#CCCCCC" StrokeThickness="1" SnapsToDevicePixels="True"/>
- </Button>
- </StackPanel>
- </Grid>
- <Grid Grid.Row="1">
- <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
- <Border Background="#141414" BorderBrush="#2E2E2E" BorderThickness="1"
- CornerRadius="4" Width="320" Height="36" Margin="0,0,0,12">
- <TextBox Name="Tx" Background="Transparent" BorderThickness="0"
- Foreground="#FFFFFF" CaretBrush="#FFFFFF" FontSize="13"
- VerticalContentAlignment="Center" Padding="10,0,10,0"
- Text="Hello World"/>
- </Border>
- <ComboBox Name="Cb" Style="{StaticResource CB}"
- ItemContainerStyle="{StaticResource CBI}"
- Width="130" Margin="0,0,0,12">
- <ComboBoxItem Content="Normal" Tag="0" IsSelected="True"/>
- <ComboBoxItem Content="Info" Tag="1"/>
- <ComboBoxItem Content="Warning" Tag="2"/>
- <ComboBoxItem Content="Error" Tag="3"/>
- </ComboBox>
- <Button Name="Bp" Content="Execute" Width="130" Height="36"
- Background="#FFFFFF" Foreground="#000000" BorderThickness="0"
- FontSize="14" FontWeight="SemiBold" Cursor="Hand">
- <Button.Template>
- <ControlTemplate TargetType="Button">
- <Border x:Name="bb" Background="{TemplateBinding Background}" CornerRadius="4">
- <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
- </Border>
- <ControlTemplate.Triggers>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter TargetName="bb" Property="Background" Value="#E5E5E5"/>
- </Trigger>
- <Trigger Property="IsPressed" Value="True">
- <Setter TargetName="bb" Property="Background" Value="#CCCCCC"/>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Button.Template>
- </Button>
- </StackPanel>
- </Grid>
- </Grid>
- </Border>
- </Window>
- '@
- $r = New-Object System.Xml.XmlNodeReader $x
- $w = [Windows.Markup.XamlReader]::Load($r)
- $tb = $w.FindName("TB")
- $bn = $w.FindName("Bn")
- $bc = $w.FindName("Bc")
- $bp = $w.FindName("Bp")
- $tx = $w.FindName("Tx")
- $cb = $w.FindName("Cb")
- $tb.Add_MouseLeftButtonDown({ $w.DragMove() })
- $bn.Add_Click({ $w.WindowState = 'Minimized' })
- $bc.Add_Click({ $w.Close() })
- $bp.Add_Click({ [P]::Send($tx.Text, [int]$cb.SelectedItem.Tag) })
- $w.ShowDialog() | Out-Null
Add Comment
Please, Sign In to add comment