StackZero
  • Homepage
  • Cryptography and Privacy
  • Ethical Hacking
  • Reverse Engineering
  • Contacts
  • About Me
No Result
View All Result
StackZero
No Result
View All Result

How to prank your friends with this hilarious wallpaper locker!

June 6, 2022
in Ethical Hacking
0 0
How to prank your friends with this hilarious wallpaper locker!
0
SHARES
70
VIEWS
Share on FacebookShare on Twitter

If you’ve ever wanted to pull a prank on your friends by locking their wallpaper, this is the article for you!
I’ll explain how to do it in just a few simple steps. So that your victim could not replace the embarrassing image you choose. The result will be a simple script: “wallpaper locker”

Wallpaper locker building strategy

Windows has two registry entries that we’re interested in.

  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\Wallpaper
  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\WallpaperStyle

The first one is a string representing the path of the new Wallpaper.
The second one is a number indicating the Style:

  • 0 – Centered
  • 1 – Tiled
  • 2 – Stretched
  • 3 – Fit
  • 4 – Fill

Currently, they probably don’t exist on your friend’s PC, so let’s just write what we are going to do:

  • Move the selected wallpaper into a hard-to-find directory
  • Create the “System” key
  • Create the two values: Wallpaper and WallpaperStyle
  • Reboot the system

Practice Part

Before starting coding, just to hide our intentions, let’s rename the target wallpaper image with a deceptive name and a different extension, like: “sys.conf”.

Done that, we can create our script file that I named “change-bg.py” in this example. Optionally, you can create a virtual environment.

Structure after file creation

Our code will use winreg as we’ve done in this article.

But now stop talking and write our script!

The first thing we want to do is just initialize all variables and do all imports:

import winreg
import os
import shutil

bg_location = "C:\\Windows"
base_key = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"
img_name = "sys.conf"

keys = {
    "Wallpaper": (f"C:\\Windows\\{img_name}", winreg.REG_SZ),
    "WallpaperStyle": ("3", winreg.REG_SZ)
}

I just want to point out that we saved the value we want to pass in a dictionary, having the registry key name as the key and a tuple containing value and size as dictionary value.

The next step is to copy the wallpaper from the current directory to another one (“C:\Windows” in our case).

shutil.copy("sys.conf", f"{bg_location}")

We have almost done, this is the step where we are connecting to the registry and adding the key and all values that we set into the dictionary:

reg = winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER)
system_key = winreg.CreateKey(reg, base_key)

for k, v in keys.items():
    winreg.SetValueEx(system_key, k, 0,  v[1], v[0])

Finally, let’s reboot the system in the simplest way possible:

os.system("shutdown /r /t 0")

If we want to make the prank more insidious, we can convert the script into an executable, as this article shows.

This is the full code:

import winreg
import os
import shutil

bg_location = "C:\\Windows"
base_key = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"
img_name = "sys.conf"

keys = {
    "Wallpaper": (f"C:\\Windows\\{img_name}", winreg.REG_SZ),
    "WallpaperStyle": ("3", winreg.REG_SZ)
}

shutil.copy("sys.conf", f"{bg_location}")
reg = winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER)
system_key = winreg.CreateKey(reg, base_key)

for k, v in keys.items():
    winreg.SetValueEx(system_key, k, 0,  v[1], v[0])

os.system("shutdown /r /t 0")

If we want to run we need to open a command line as administrator and write;

python change-bg.py

In the case of the executable, just right-click -> “Run as administrator”.

Now it’s impossible to change the Wallpaper from the screen settings.

Finally, if we want to sort everything out, let’s just write a few lines of script that will remove the key from the registry and call this script “clear-reg.py”:

import winreg

reg = winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER)
winreg.DeleteKey(reg, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System")

After running the clear-reg.py, your friend will be able again to change his desktop!

I hope you found this article interesting, have fun with that!

Subdomain scanner made easy – with Python!
Trending
Subdomain scanner made easy – with Python!

Tags: ethical hackingpython
Previous Post

Compilation Process in C: Easy Introduction

Next Post

OWASP Top 10 Breaches of 2021. What You Need to Know!

Next Post
OWASP Top 10 Breaches of 2021. What You Need to Know!

OWASP Top 10 Breaches of 2021. What You Need to Know!

You might also like

Cryptographic functions

Cryptographic Hash Functions in Python: Secure Your Data Easily

November 3, 2024
Malware Obfuscation Techniques: All That You Need To Know

Malware Obfuscation Techniques: All That You Need To Know

March 25, 2024
How To Do Process Enumeration: An Alternative Way

How To Do Process Enumeration: An Alternative Way

March 4, 2024
How To Do DLL Injection: An In-Depth Cybersecurity Example

How To Do DLL Injection: An In-Depth Cybersecurity Example

February 8, 2024
Process Injection By Example: The Complete Guide

Process Injection By Example: The Complete Guide

January 24, 2024
How To Build Your Own: Python String Analysis for Malware Insights

How To Build Your Own: Python String Analysis for Malware Insights

November 10, 2023

StackZero

StackZero is a specialized technical blog dedicated to the realm of cybersecurity. It primarily provides insightful articles and comprehensive tutorials designed to educate readers on developing security tools. The blog encompasses a broad spectrum of subjects, starting from the foundational principles of cryptography and extending to more sophisticated areas such as exploitation and reverse engineering. This makes StackZero an invaluable resource for both beginners and professionals in the field of cybersecurity.
The blog covers a wide range of topics, from the basics of cryptography to the more advanced topics of exploitation and reverse engineering.

Tags

application security blind sqli blind sql injection bruteforce c cesar cipher command injection cryptography ctf cybersecurity debugging dom-based xss dvwa ethical-hacking ethical hacking exploitation file inclusion gdb hacking injection javascript malware malware analysis malware evasion network-security pentesting lab picoctf pico ctf python reflected xss reverse engineering sql sqli sql injection static analysis stored xss substitution substitution cipher vulnerable application web application security web exploitation web security windows windows api xss
  • About Me
  • Contacts
  • HomePage
  • Opt-out preferences
  • Privacy Policy
  • Terms and Conditions

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Manage Cookie Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
View preferences
{title} {title} {title}
No Result
View All Result
  • Homepage
  • Cryptography and Privacy
  • Ethical Hacking
  • Reverse Engineering
  • Contacts
  • About Me