ptnote 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ptnote/__init__.py ADDED
@@ -0,0 +1 @@
1
+ __version__ = "1.0.0"
ptnote/cli.py ADDED
@@ -0,0 +1,205 @@
1
+ #!/usr/bin/env python3
2
+ import argparse
3
+ import os
4
+ import json
5
+ from . import config_settings
6
+ from .config_settings import save_config
7
+ import shutil
8
+
9
+ CLEAR_NOTE = """Target:
10
+ Admin:
11
+ IP:
12
+ Domain:
13
+ ====================
14
+ """
15
+ FIELDS = {
16
+ "admin": "Admin:",
17
+ "ip": "IP:",
18
+ "domain": "Domain:"
19
+ }
20
+
21
+ def update_field(file_path, field, value):
22
+ if os.path.exists(file_path):
23
+ with open(file_path, "r", encoding="utf-8") as file:
24
+ lines = file.readlines()
25
+ for i, line in enumerate(lines):
26
+ if line.startswith(field):
27
+ lines[i] = f"{field} {value}\n"
28
+ with open(file_path, "w", encoding="utf-8") as file:
29
+ file.writelines(lines)
30
+ return True
31
+ return False
32
+
33
+ def main():
34
+ home = os.path.expanduser("~")
35
+ filelocation = os.path.join(home, ".ptnote", "notes")
36
+ parser = argparse.ArgumentParser()
37
+ subparsers = parser.add_subparsers(dest="command")
38
+
39
+ new_parser = subparsers.add_parser("new")
40
+ new_parser.add_argument("name")
41
+
42
+ clear_parser = subparsers.add_parser("clear")
43
+ clear_parser.add_argument("name")
44
+
45
+ select = subparsers.add_parser("select")
46
+ select.add_argument("selected_note")
47
+
48
+ show = subparsers.add_parser("show")
49
+ show.add_argument("show_note")
50
+
51
+ delete = subparsers.add_parser("delete")
52
+ delete.add_argument("delete_selected_note")
53
+
54
+ add_note = subparsers.add_parser("add")
55
+ add_note.add_argument("note")
56
+
57
+ list_all_notes = subparsers.add_parser("list")
58
+
59
+ set_parser = subparsers.add_parser("set")
60
+ set_parser.add_argument("field")
61
+ set_parser.add_argument("value")
62
+
63
+ rename = subparsers.add_parser("rename")
64
+ rename.add_argument("old_note_name")
65
+ rename.add_argument("new_note_name")
66
+
67
+ current = subparsers.add_parser("current")
68
+
69
+ args = parser.parse_args()
70
+
71
+ if args.command == "new":
72
+ os.makedirs(filelocation, exist_ok=True)
73
+ os.makedirs(os.path.join(filelocation, args.name), exist_ok=True)
74
+ file = os.path.join(filelocation, args.name, f"{args.name}.txt")
75
+ with open(file, "a", encoding="utf-8") as new_file:
76
+ new_file.write(CLEAR_NOTE)
77
+ print(f"New note is created: {file}")
78
+
79
+ elif args.command == "clear":
80
+ file = os.path.join(filelocation, args.name, f"{args.name}.txt")
81
+ if os.path.exists(file):
82
+ with open(file, "w", encoding="utf-8") as clear_file:
83
+ clear_file.write(CLEAR_NOTE)
84
+ else:
85
+ print('Error: Unknown file name')
86
+
87
+ elif args.command == "select":
88
+ file = os.path.join(filelocation, args.selected_note, f"{args.selected_note}.txt")
89
+ if os.path.exists(file):
90
+ config = config_settings.load_config()
91
+ config['active_note'] = args.selected_note
92
+ config_settings.save_config(config)
93
+ print(f"Active note changed: {args.selected_note}")
94
+ else:
95
+ print("Error: Unknown file name")
96
+
97
+ elif args.command == "set":
98
+ if args.field not in FIELDS:
99
+ print("Error: Unknown field")
100
+ return
101
+ config = config_settings.load_config()
102
+ active_note = config["active_note"]
103
+
104
+ if active_note:
105
+ file_path = os.path.join(
106
+ filelocation,
107
+ active_note,
108
+ f"{active_note}.txt"
109
+ )
110
+
111
+ result = update_field(
112
+ file_path,
113
+ FIELDS[args.field],
114
+ args.value
115
+ )
116
+ if result:
117
+ print(f"{FIELDS[args.field]} {args.value}")
118
+ else:
119
+ print("Error: Field not found")
120
+ else:
121
+ print("Error: No active note selected")
122
+
123
+ elif args.command == "show":
124
+ file = os.path.join(filelocation, args.show_note, f"{args.show_note}.txt")
125
+ if os.path.exists(file):
126
+ with open(file, "r", encoding="utf-8") as show_file:
127
+ content = show_file.read()
128
+ print(content)
129
+ else:
130
+ print("Error: Unknown file name")
131
+
132
+ elif args.command == "list":
133
+ note = os.listdir(filelocation)
134
+ print(note)
135
+
136
+ elif args.command == "delete":
137
+ path = os.path.join(filelocation, args.delete_selected_note)
138
+ config = config_settings.load_config()
139
+ if args.delete_selected_note == config["active_note"]:
140
+ if os.path.exists(path):
141
+ yesOrNo = input("Are you sure you want to delete this note? (y/N): ")
142
+ if yesOrNo == "y" or yesOrNo == "Y":
143
+ shutil.rmtree(path)
144
+ config["active_note"] = None
145
+ config_settings.save_config(config)
146
+ print(f"Deleted selected note: {args.delete_selected_note}")
147
+ else:
148
+ print("transaction canceled")
149
+ else:
150
+ print("Error: Unknown file name")
151
+ elif args.delete_selected_note != config["active_note"]:
152
+ if os.path.exists(path):
153
+ yesOrNo = input("Are you sure you want to delete this note? (y/N): ")
154
+ if yesOrNo == "y" or yesOrNo == "Y":
155
+ shutil.rmtree(path)
156
+ print(f"Deleted selected note: {args.delete_selected_note}")
157
+ else:
158
+ print("transaction canceled")
159
+ else:
160
+ print("Error: Unknown file name")
161
+
162
+ elif args.command == "add":
163
+ config = config_settings.load_config()
164
+ if config["active_note"] != None:
165
+ note = os.path.join(filelocation, config["active_note"], f"{config['active_note']}.txt")
166
+ with open(note, "a", encoding="utf-8") as new_file:
167
+ new_file.write(args.note + "\n")
168
+ print("Note added")
169
+ else:
170
+ print("Error: No active note selected")
171
+
172
+ elif args.command == "rename":
173
+ old_folder = os.path.join(
174
+ filelocation,
175
+ args.old_note_name
176
+ )
177
+
178
+ new_folder = os.path.join(filelocation, args.new_note_name)
179
+ if os.path.exists(old_folder):
180
+ os.rename(old_folder, new_folder)
181
+ old_file = os.path.join(new_folder, f"{args.old_note_name}.txt")
182
+ new_file = os.path.join(new_folder, f"{args.new_note_name}.txt")
183
+
184
+ os.rename(old_file, new_file)
185
+
186
+ config = config_settings.load_config()
187
+ if config["active_note"] == args.old_note_name:
188
+ config["active_note"] = args.new_note_name
189
+
190
+ config_settings.save_config(config)
191
+ print(
192
+ f"Renamed {args.old_note_name} -> {args.new_note_name}"
193
+ )
194
+
195
+ else:
196
+ print("Error: Unknown note")
197
+
198
+ elif args.command == "current":
199
+ config = config_settings.load_config()
200
+ if config["active_note"] != None:
201
+ print("Current File: " + config["active_note"])
202
+ else:
203
+ print("No active notes")
204
+ if __name__ == "__main__":
205
+ main()
@@ -0,0 +1,23 @@
1
+ import json
2
+ import os
3
+
4
+ PTNOTE_DIR = os.path.join(os.path.expanduser("~"), ".ptnote")
5
+ CONFIG_FILE = os.path.join(PTNOTE_DIR, "config.json")
6
+
7
+ def load_config():
8
+ os.makedirs(PTNOTE_DIR, exist_ok=True)
9
+ if os.path.exists(CONFIG_FILE):
10
+ with open(CONFIG_FILE, "r", encoding="utf-8") as file:
11
+ return json.load(file)
12
+
13
+ config = {
14
+ "active_note": None
15
+ }
16
+
17
+ save_config(config)
18
+ return config
19
+
20
+
21
+ def save_config(config):
22
+ with open(CONFIG_FILE, "w", encoding="utf-8") as file:
23
+ json.dump(config, file, indent=4)
@@ -0,0 +1,209 @@
1
+ Metadata-Version: 2.4
2
+ Name: ptnote
3
+ Version: 1.0.0
4
+ Summary: A fast terminal note manager for penetration testers.
5
+ Author: Salih
6
+ License: ## License
7
+
8
+ PtNote is licensed under the PolyForm Noncommercial License 1.0.0.
9
+
10
+ You may use, modify, and share PtNote for personal, educational, and non-commercial purposes.
11
+
12
+ Commercial use requires explicit permission from the author.
13
+ Keywords: pentest,ctf,notes,security,terminal
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Environment :: Console
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Dynamic: license-file
21
+
22
+ # PtNote
23
+
24
+ **PtNote** is a lightweight terminal-based note manager designed for penetration testers and CTF players. It lets you quickly create, organize, and manage notes directly from the command line without leaving your workflow.
25
+
26
+ ## Features
27
+
28
+ - Create separate notes for each target
29
+ - Select an active note
30
+ - Add notes instantly
31
+ - Display note contents
32
+ - Clear a note while preserving the template
33
+ - List all available notes
34
+ - Set target information
35
+ - Admin
36
+ - IP Address
37
+ - Domain
38
+ - Rename existing notes
39
+ - Delete notes
40
+ - Show the currently selected note
41
+
42
+ ---
43
+
44
+ # Installation
45
+
46
+ ```bash
47
+ pip install ptnote
48
+ ```
49
+
50
+ ---
51
+
52
+ # Usage
53
+
54
+ ## Create a new note
55
+
56
+ ```bash
57
+ ptnote new target1
58
+ ```
59
+
60
+ Creates a new note using the default template.
61
+
62
+ ---
63
+
64
+ ## Select a note
65
+
66
+ ```bash
67
+ ptnote select target1
68
+ ```
69
+
70
+ Sets the selected note as the active note.
71
+
72
+ ---
73
+
74
+ ## Add a note
75
+
76
+ ```bash
77
+ ptnote add "Found SQL Injection on /login"
78
+ ```
79
+
80
+ Appends a new line to the active note.
81
+
82
+ ---
83
+
84
+ ## Show a note
85
+
86
+ ```bash
87
+ ptnote show target1
88
+ ```
89
+
90
+ Displays the contents of the specified note.
91
+
92
+ ---
93
+
94
+ ## Clear a note
95
+
96
+ ```bash
97
+ ptnote clear target1
98
+ ```
99
+
100
+ Resets the note to the default template.
101
+
102
+ ---
103
+
104
+ ## List notes
105
+
106
+ ```bash
107
+ ptnote list
108
+ ```
109
+
110
+ Lists all available notes.
111
+
112
+ ---
113
+
114
+ ## Set target information
115
+
116
+ Set administrator:
117
+
118
+ ```bash
119
+ ptnote set admin administrator
120
+ ```
121
+
122
+ Set IP address:
123
+
124
+ ```bash
125
+ ptnote set ip 192.168.1.10
126
+ ```
127
+
128
+ Set domain:
129
+
130
+ ```bash
131
+ ptnote set domain example.com
132
+ ```
133
+
134
+ ---
135
+
136
+ ## Rename a note
137
+
138
+ ```bash
139
+ ptnote rename target1 target2
140
+ ```
141
+
142
+ Renames both the note folder and its file.
143
+
144
+ ---
145
+
146
+ ## Delete a note
147
+
148
+ ```bash
149
+ ptnote delete target2
150
+ ```
151
+
152
+ Deletes the specified note after confirmation.
153
+
154
+ ---
155
+
156
+ ## Show current active note
157
+
158
+ ```bash
159
+ ptnote current
160
+ ```
161
+
162
+ Displays the currently selected note.
163
+
164
+ ---
165
+
166
+ # Default Note Template
167
+
168
+ Every new note starts with the following template:
169
+
170
+ ```text
171
+ Target:
172
+ Admin:
173
+ IP:
174
+ Domain:
175
+ ====================
176
+ ```
177
+
178
+ ---
179
+
180
+ # Data Storage
181
+
182
+ PtNote stores all notes locally inside:
183
+
184
+ ```text
185
+ ~/.ptnote/
186
+ ```
187
+
188
+ Notes are stored locally, with each target having its own directory and note file.
189
+
190
+ ---
191
+
192
+ # License
193
+
194
+ This project is licensed under the PolyForm Noncommercial License 1.0.0.
195
+
196
+ You may use, modify, and share PtNote for personal, educational, and non-commercial purposes.
197
+
198
+ Commercial use requires explicit permission from the author.
199
+ This project is licensed under the P # License
200
+
201
+ This project is licensed under the PolyForm Noncommercial License 1.0.0.
202
+
203
+ You may use, modify, and share PtNote for personal, educational, and non-commercial purposes.
204
+
205
+ Commercial use requires explicit permission from the author.
206
+
207
+ ## Disclaimer
208
+
209
+ PtNote is intended for authorized security testing, CTF competitions, and educational purposes only.
@@ -0,0 +1,9 @@
1
+ ptnote/__init__.py,sha256=Aj77VL1d5Mdku7sgCgKQmPuYavPpAHuZuJcy6bygQZE,21
2
+ ptnote/cli.py,sha256=XESqffWnZjhxS9zjGIVrBgGlY-7uED7ByaqYz9LW-0E,7004
3
+ ptnote/config_settings.py,sha256=pMd3nIpl-NWQ3KKfov-Fwza982qTH07xYZVJxGM5D8Y,556
4
+ ptnote-1.0.0.dist-info/licenses/LICENSE,sha256=WMGKe7lzIj-3duP6RSYpB9Mtmy02p7btcsYkL21A_1k,235
5
+ ptnote-1.0.0.dist-info/METADATA,sha256=I8hbX89OnLWPO_Yknkrd4mebInykfnhbSlJc7FQBtyU,3408
6
+ ptnote-1.0.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
7
+ ptnote-1.0.0.dist-info/entry_points.txt,sha256=91jBPttSVLnXuKtTe7l1sw7c2tXg45Qxa_Iii9wdOAg,43
8
+ ptnote-1.0.0.dist-info/top_level.txt,sha256=Pcgycsh5-mR-g_92Gini_lyGcAjFbG4XXHQvJkTTt9I,7
9
+ ptnote-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (83.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ptnote = ptnote.cli:main
@@ -0,0 +1,7 @@
1
+ ## License
2
+
3
+ PtNote is licensed under the PolyForm Noncommercial License 1.0.0.
4
+
5
+ You may use, modify, and share PtNote for personal, educational, and non-commercial purposes.
6
+
7
+ Commercial use requires explicit permission from the author.
@@ -0,0 +1 @@
1
+ ptnote