mirror of
https://github.com/beigeworm/BadUSB-Files-For-FlipperZero.git
synced 2025-12-31 07:00:51 -08:00
Update main.ps1
This commit is contained in:
@@ -26,7 +26,7 @@ while ($true){
|
||||
$header = "
|
||||
===============================================
|
||||
|
||||
=========== MOUSE CLICKS RECORDER ===========
|
||||
=========== MOUSE CLICK RECORDER ============
|
||||
|
||||
===============================================
|
||||
|
||||
@@ -42,7 +42,9 @@ while ($true){
|
||||
$option = Read-Host "Please Select an Option "
|
||||
|
||||
if ($option -eq 1){
|
||||
$sequencefile = "$env:TEMP/sequence.ps1"
|
||||
$sequencefile = "$env:TEMP\sequence.ps1"
|
||||
$fullPath = (Get-Item $sequencefile).FullName
|
||||
$sequencefileforc = $fullPath -replace '\\', '\\'
|
||||
Write-Host "Creating a file.."
|
||||
|
||||
"# ===================================== CLICK SEQUENCER ========================================" | Out-File -FilePath $sequencefile -Force
|
||||
@@ -85,7 +87,91 @@ while ($true){
|
||||
|
||||
Write-Host "Setting up..." -ForegroundColor Yellow
|
||||
sleep 1
|
||||
|
||||
Add-Type @"
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
public class MouseHook
|
||||
{
|
||||
public delegate IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern IntPtr SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hMod, uint dwThreadId);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool UnhookWindowsHookEx(IntPtr hhk);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
public const int WH_MOUSE_LL = 14;
|
||||
public const int WM_MOUSEWHEEL = 0x020A;
|
||||
|
||||
private static HookProc _proc = HookCallback;
|
||||
private static IntPtr _hookID = IntPtr.Zero;
|
||||
|
||||
private static Encoding encoding = Encoding.Unicode;
|
||||
private static string logFilePath = "$sequencefileforc";
|
||||
|
||||
public static void Start()
|
||||
{
|
||||
_hookID = SetHook(_proc);
|
||||
}
|
||||
|
||||
public static void Stop()
|
||||
{
|
||||
UnhookWindowsHookEx(_hookID);
|
||||
}
|
||||
|
||||
private static IntPtr SetHook(HookProc proc)
|
||||
{
|
||||
using (var curProcess = System.Diagnostics.Process.GetCurrentProcess())
|
||||
using (var curModule = curProcess.MainModule)
|
||||
{
|
||||
return SetWindowsHookEx(WH_MOUSE_LL, proc, GetModuleHandle(curModule.ModuleName), 0);
|
||||
}
|
||||
}
|
||||
|
||||
private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
|
||||
{
|
||||
if (nCode >= 0 && wParam == (IntPtr)WM_MOUSEWHEEL)
|
||||
{
|
||||
int delta = Marshal.ReadInt32(lParam, 8);
|
||||
string message;
|
||||
if (delta > 0)
|
||||
{
|
||||
message = "[MouseSimulator]::ScrollUp()";
|
||||
}
|
||||
else if (delta < 0)
|
||||
{
|
||||
message = "[MouseSimulator]::ScrollDown()";
|
||||
}
|
||||
else
|
||||
{
|
||||
return CallNextHookEx(_hookID, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
using (StreamWriter writer = new StreamWriter(logFilePath, true, encoding))
|
||||
{
|
||||
writer.WriteLine(message);
|
||||
}
|
||||
}
|
||||
return CallNextHookEx(_hookID, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
private static extern IntPtr GetModuleHandle(string lpModuleName);
|
||||
}
|
||||
"@
|
||||
|
||||
# Start the mouse hook
|
||||
[MouseHook]::Start()
|
||||
|
||||
function MouseState {
|
||||
|
||||
$previousState = [System.Windows.Forms.Control]::MouseButtons
|
||||
$previousPosition = [System.Windows.Forms.Cursor]::Position
|
||||
$lastClickTime = $null
|
||||
@@ -160,7 +246,10 @@ function MouseState {
|
||||
Write-Host "Recording..." -ForegroundColor Red
|
||||
while ($true) {
|
||||
MouseState
|
||||
}
|
||||
}
|
||||
|
||||
[MouseHook]::Stop()
|
||||
|
||||
}
|
||||
|
||||
if ($option -eq 2){
|
||||
|
||||
Reference in New Issue
Block a user