Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

Commit

Permalink
Merge branch 'main' into fix-205
Browse files Browse the repository at this point in the history
  • Loading branch information
yashksaini-coder authored Nov 7, 2024
2 parents 3ccc846 + 0c7b7d9 commit e78cb54
Show file tree
Hide file tree
Showing 17 changed files with 119 additions and 202 deletions.
2 changes: 1 addition & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Changelog
# **Changelog**
## [Stable-Release]

## v1.0.1 - 19-10-2024
Expand Down
2 changes: 1 addition & 1 deletion docs/LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# License
# **License**

The project works by highlighting and improving security measures by demonstrating potential vulnerabilities when the system is connected with pip. It is licensed under the [GPL 3.0](https://www.gnu.org/licenses/gpl-3.0.en.html), allowing you to sneakily use and modify it as needed.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Getting Started
# **Home**

### **[What is Sneaky Package?](index.md)**
A ready-to-deploy Python package designed to 🕵️‍♂️ stealthily integrate files within a machine, ensuring 🛡️ discreet and seamless file operations without detection.
Expand Down
64 changes: 0 additions & 64 deletions package/clip.py

This file was deleted.

10 changes: 0 additions & 10 deletions package/display.py

This file was deleted.

Empty file added package/offline/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions package/offline/clip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import os
from package.offline.support import copy_to_clipboard
from package.offline.support import display


def clip(snippet_name, password):
display(snippet_name, password, action="copy")
13 changes: 13 additions & 0 deletions package/offline/show.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os
from package.offline.support import list_snippets, display
from package.password import valid_password


def show(snippet_name=None, password=None):
if snippet_name is None and password is None:
base_dir = os.path.dirname(__file__)
snippets_dir = os.path.join(base_dir, "stash")
list_snippets(snippets_dir)
return

display(snippet_name, password, action="display")
Empty file.
30 changes: 30 additions & 0 deletions package/offline/support/copy_to_clipboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import subprocess
import sys
import shutil


def copy_to_clipboard(text):
try:
if "linux" in sys.platform:
if shutil.which("xclip") is None:
raise RuntimeError("xclip not found. Install it.")
subprocess.run(
["xclip", "-selection", "clipboard"],
input=text.strip().encode(),
check=True,
)

elif "win32" in sys.platform:
subprocess.run(
["C:\\Windows\\System32\\clip.exe"],
input=text.strip().encode(),
check=True,
)

elif "darwin" in sys.platform:
subprocess.run(["/usr/bin/pbcopy"], input=text.strip().encode(), check=True)

else:
raise OSError("Unsupported operating system")
except subprocess.CalledProcessError:
print("Error: Failed to copy to clipboard.")
26 changes: 26 additions & 0 deletions package/offline/support/display.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os
from package.offline.support import copy_to_clipboard
from package.password import valid_password


def display(snippet_name, password, action):
if not isinstance(password, int) or not valid_password(password):
raise ValueError("Incorrect password")

base_dir = os.path.dirname(__file__)
snippets_dir = os.path.join(base_dir, "stash")

try:
snippet_path = os.path.join(snippets_dir, snippet_name)
with open(snippet_path, "r") as file:
content = file.read()

if action == "display":
print(content)
elif action == "copy":
copy_to_clipboard(content)
print("Snippet copied to clipboard.")
except FileNotFoundError:
print("Error: No file found with the specified name.")
except Exception as e:
print(f"Error: {e}")
12 changes: 12 additions & 0 deletions package/offline/support/list_snippets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os


def list_snippets(snippets_dir):
try:
contents = os.listdir(snippets_dir)
for file in contents:
print(file)
except FileNotFoundError:
print("Error: Stash directory not found.")
except Exception as e:
print(f"Error: {e}")
22 changes: 22 additions & 0 deletions package/offline/write.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import shutil
import os
from package.password import valid_password


def write(snippet_name, password):
if not isinstance(password, int) or not valid_password(password):
raise ValueError("Incorrect password")

base_dir = os.path.dirname(__file__)
snippets_dir = os.path.join(base_dir, "stash")

try:
snippet_path = os.path.join(snippets_dir, snippet_name)
output_path = os.path.join(base_dir, snippet_name)

shutil.copyfile(snippet_path, output_path)
print(f"File '{snippet_path}' copied successfully to '{output_path}'.")
except FileNotFoundError:
print("Error: No file found with the specified name.")
except Exception as e:
print(f"Error: {e}")
6 changes: 6 additions & 0 deletions package/password.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from datetime import datetime


def valid_password(password: int) -> bool:
current_time = int(datetime.now().strftime("%H%M"))
return password == current_time
84 changes: 0 additions & 84 deletions package/show.py

This file was deleted.

5 changes: 0 additions & 5 deletions package/test.py

This file was deleted.

36 changes: 0 additions & 36 deletions package/write.py

This file was deleted.

0 comments on commit e78cb54

Please sign in to comment.