Zero-dependency cross-platform mouse control using native OS APIs
A lightweight post-exploitation research tool for testing endpoint detection and response (EDR) capabilities against dependency-free payloads.
Ghostmove provides programmatic mouse control across Windows, Linux, and macOS without any external dependencies. Built using direct OS API bindings via Python's ctypes, this tool demonstrates how to interact with low-level system interfaces for red team operations.
Traditional automation libraries (PyAutoGUI, pyautogui, etc.) require pip installation and create large dependency trees - easily detected by EDR solutions. This project explores minimal-footprint cursor control using only Python standard library + native OS APIs.
Use Cases:
- Red Team: Post-exploitation persistence testing
- Blue Team: Understanding evasion techniques for better detection
- Research: EDR bypass methodology
- Education: Learning OS API interaction
- Windows: Direct
user32.dllbindings (SetCursorPos, GetCursorPos) - Linux X11:
libX11.sointegration (XWarpPointer, XQueryPointer) - macOS: Quartz/CoreGraphics (CGEventCreateMouseEvent)
jitter- Random micro-movements (simulates hardware glitch)drift- Slow movement toward screen cornerscircle- Circular motion patternsevasion- Cursor jumps away when user moves itdrunk- Wobbly, erratic movementsgravity- Constant pull toward screen centerchaos- Randomly switches between all patterns
- Pure Python 3.7+ (no pip install required)
- Works with standard library only
- Entire payload: ~15KB
- Runs in restricted/air-gapped environments
git clone https://github.com/YOUR_USERNAME/phantom-cursor.git
cd phantom-cursorNo pip install needed!
# Random jitter for 60 seconds
python phantom_cursor.py --mode jitter --duration 60
# Drift to bottom-right corner
python phantom_cursor.py --mode drift --duration 30
# Evasion mode (cursor runs from user)
python phantom_cursor.py --mode evasion --duration 120
# Chaos mode (random patterns)
python phantom_cursor.py --mode chaos --duration 60from phantom_cursor import get_cursor_controller
# Get platform-appropriate controller
cursor = get_cursor_controller()
# Move to absolute position
cursor.move_to(500, 300)
# Move relative to current position
cursor.move_relative(10, -20)
# Get current position
x, y = cursor.get_position()
# Get screen dimensions
width, height = cursor.get_screen_size()Traditional automation (PyAutoGUI):
Process: python.exe
Loaded modules: pyautogui.pyd, PIL.pyd, numpy.pyd, ...
Signature: Known automation library
Detection: ✅ Flagged immediately
Ghostmove:
Process: python.exe
Loaded modules: ctypes (standard library)
Signature: Direct OS API calls (legitimate use)
Detection: ⚠️ Requires behavioral analysis
Blue team should monitor:
- Unusual cursor movement patterns (velocity, acceleration analysis)
- Cursor activity when user input devices are idle
- Process making excessive cursor API calls
- Correlation with other suspicious behaviors
Detection strategies:
- Behavioral analysis (movement pattern recognition)
- User input device correlation (keyboard/mouse hardware events)
- Process reputation and parent process analysis
Uses ctypes.windll.user32:
SetCursorPos(x, y)- Absolute positioningGetCursorPos(POINT*)- Current positionGetSystemMetrics()- Screen dimensions
Uses libX11.so via ctypes:
XWarpPointer()- Cursor movementXQueryPointer()- Position retrievalXDisplayWidth/Height()- Screen size
Uses Quartz framework:
CGEventCreateMouseEvent()- Create mouse eventCGEventPost()- Post event to the systemCGEventGetLocation()- Get cursor position
FOR EDUCATIONAL AND AUTHORIZED TESTING ONLY
This tool is provided for:
- Security research
- Authorized penetration testing
- Educational purposes
- Red team exercises with proper authorization
Unauthorized use is illegal and unethical.
Always obtain written permission before testing on systems you don't own.
Contributions welcome! Areas for improvement:
- Wayland support for modern Linux
- Additional movement patterns
- Stealth/evasion improvements
- Detection bypass techniques
- Performance optimizations
Contribution to: 100 Red Team Projects
MIT License - See LICENSE file for details
Manthan Ghasadiya
- GitHub: @manthanghasadiya
- LinkedIn: Manthan Ghasadiya
Built with ❤️ for the red team community