Skip to content

Instantly share code, notes, and snippets.

@Shadow0ps
Created January 12, 2024 07:15
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shadow0ps/a7dc9fbd84617d1c1da1d125c3b38aba to your computer and use it in GitHub Desktop.
Save Shadow0ps/a7dc9fbd84617d1c1da1d125c3b38aba to your computer and use it in GitHub Desktop.
Converts ASCII Prompts to Unicode Generating “Invisible” Prompts
#This script helps generate unicode which is essentially hidden or "invisible" but is easily read by LLM's especially those that do not rely on a UI or Prescreening of prompts via API submission.
#This wont be published until someone else discovers it as its too "valuable" to threat actors to publish given currently available mitigations.
# V1.0: TLP RED! Do Not Distribute! Category: Hidden Injection Prompt! - 09/2023 - ShadowOpz
# V2.0: TLP RED! Feature update: Added invisible clipboard functionality.
# V3.0: Public Disclosure from Twitter discovered. Notes below.
# V3.0 Notes: Released to public Gist 01/12/2024 after public disclosure from Twitter.
# Kudos to @rezo_ and @goodside for the discovery and their pyperclip version.
import tkinter as tk
def convert_to_tag_chars(input_string):
"""
Convert each character of the input string to a corresponding character
in a specific Unicode range starting at 0xE0000.
Parameters:
input_string (str): The string to convert.
Returns:
str: A string where each character has been converted to a different Unicode character.
"""
try:
return ''.join(chr(0xE0000 + ord(ch)) if 0xE0000 + ord(ch) <= 0xE007F else ch for ch in input_string)
except Exception as e:
print(f"Error during conversion: {e}")
return None
def copy_to_clipboard(string):
root = tk.Tk()
root.withdraw() # We hidethe Tkinter window
root.clipboard_clear()
root.clipboard_append(string)
root.update() # Data stays on the clipboard after the window is closed
root.destroy()
while True:
user_input = input("Enter a string to convert to tag characters (or 'exit' to quit): ")
if user_input.lower() == 'exit':
break
tagged_output = convert_to_tag_chars(user_input)
if tagged_output:
print("Tagged output:", tagged_output)
copy_to_clipboard(tagged_output)
else:
print("Failed to convert the input.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment