-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the ability to create initialization scripts
- Loading branch information
1 parent
e1c4ef3
commit 8cce7cc
Showing
7 changed files
with
138 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
import argparse | ||
|
||
from .generation_init_script import generation_script | ||
from ..log4ck import * | ||
|
||
|
||
PWN_SCRIPT_NAME = r""" | ||
_ ____ _ _ | ||
___| | ___ _ __ _ _ __ _ ____ ___ __ / ___| ___ _ __(_)_ __ | |_ | ||
/ __| |/ / | | |/ _` | '_ \ | '_ \ \ /\ / / '_ \\___ \ / __| '__| | '_ \| __| | ||
| (__| <| |_| | (_| | | | |_| |_) \ V V /| | | |___) | (__| | | | |_) | |_ | ||
\___|_|\_\\__, |\__,_|_| |_(_) .__/ \_/\_/ |_| |_|____/ \___|_| |_| .__/ \__| | ||
|___/ |_| |_| | ||
PwnScript version: 2.1.4""" + "\n\n" | ||
|
||
|
||
class CliParser: | ||
def __init__(self): | ||
self.local = True | ||
|
@@ -16,7 +27,7 @@ def __init__(self): | |
|
||
def set_parse_arguments(self): | ||
|
||
VERSION = "PwnScript: version 2.1.3\n" \ | ||
VERSION = "PwnScript: version 2.1.4\n" \ | ||
"Author: Comentropy Ckyan\n" \ | ||
"Email: [email protected]\n" \ | ||
"GitHub: https://github.com/c0mentropy/ckyan.pwnScript\n" | ||
|
@@ -30,9 +41,6 @@ def set_parse_arguments(self): | |
|
||
subparsers = parser.add_subparsers(dest='Commands', help='Available Commands') | ||
|
||
# 添加 "run" 命令 | ||
auto_parser = subparsers.add_parser('auto', aliases=['run'], help='Automatically detect attacks') | ||
|
||
# 添加 "debug" 命令 | ||
de_parser = subparsers.add_parser('debug', aliases=['de'], help='Attack locally') | ||
de_parser.add_argument('-f', '--file', type=str, help='File to debug') | ||
|
@@ -49,9 +57,20 @@ def set_parse_arguments(self): | |
re_parser.add_argument('-f', '--file', type=str, help='File to debug') | ||
re_parser.add_argument('-l', '--libc', type=str, help='File to debug') | ||
|
||
# 添加 "run" 命令 | ||
auto_parser = subparsers.add_parser('auto', aliases=['run'], help='Automatically detect attacks') | ||
|
||
# 添加 "blasting" 命令 | ||
bl_parser = subparsers.add_parser('blasting', aliases=['bl'], help='Attack blow up') | ||
|
||
# 添加 "new_file" 命令 | ||
generation_file = subparsers.add_parser('generation', aliases=['new'], help='Generate the initialization script') | ||
|
||
# 添加文件名参数 | ||
generation_file.add_argument("filename", help="The name of the file to create") | ||
# 添加 name 参数 | ||
generation_file.add_argument("-n", "--name", help="The username to use in the initialization script") | ||
|
||
# 解析命令行参数 | ||
args = parser.parse_args() | ||
|
||
|
@@ -61,7 +80,15 @@ def set_parse_arguments(self): | |
exit() | ||
|
||
# 根据子命令进行不同的处理 | ||
if args.Commands in ['de', 'debug']: | ||
if args.Commands in ['auto', 'run'] or args.Commands in ['blasting', 'bl']: | ||
return | ||
|
||
elif args.Commands in ['generation', 'new']: | ||
file_name = args.filename | ||
author_name = args.name | ||
generation_script(file_name=file_name, author_name=author_name) | ||
|
||
elif args.Commands in ['de', 'debug']: | ||
self.local = True | ||
self.binary_path = args.file | ||
|
||
|
@@ -108,4 +135,8 @@ def get_parse_arguments(self): | |
return self.local, self.binary_path, self.ip, self.port, self.remote_libc_path | ||
|
||
|
||
cli_parser = CliParser() | ||
def args_init() -> CliParser: | ||
return CliParser() | ||
|
||
|
||
# cli_parser = args_init() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
def generation_script(*, file_path: str = './', file_name: str = "exp.py", author_name: str = 'ckyan'): | ||
import os | ||
from datetime import datetime | ||
from ..log4ck import success | ||
|
||
if file_name is None: | ||
file_name = "exp.py" | ||
|
||
if author_name is None: | ||
author_name = 'ckyan' | ||
|
||
script_format = f''' | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Author: {author_name} | ||
Generation date: {datetime.now().strftime("%Y-%m-%d %H:%M:%S")} | ||
""" | ||
""" | ||
GitHub: | ||
https://github.com/c0mentropy/ckyan.pwnScript | ||
Help: | ||
python3 exp.py --help | ||
python3 exp.py debug --help | ||
python3 exp.py remote --help | ||
Local: | ||
python3 exp.py debug --file ./pwn | ||
Remote: | ||
python3 exp.py remote --ip 127.0.0.1 --port 9999 [--file ./pwn] [--libc ./libc.so.6] | ||
python3 exp.py remote --url 127.0.0.1:9999 [--file ./pwn] [--libc ./libc.so.6] | ||
""" | ||
# ./exp.py de -f ./pwn | ||
# ./exp.py re -f ./pwn -u "" | ||
from ckyan.pwnScript import * | ||
def exp(): | ||
pandora_box.init_script() | ||
elf = pandora_box.elf | ||
libc = pandora_box.libc | ||
p = pandora_box.conn | ||
if __name__ == '__main__': | ||
exp() | ||
'''.strip() | ||
|
||
result_file = os.path.join(file_path, file_name) | ||
|
||
# 打开文件并写入字符串 | ||
with open(result_file, "w") as file: | ||
file.write(script_format + "\n") | ||
|
||
success("File generated.") | ||
|
||
exit() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
from setuptools import setup, find_packages | ||
setup( | ||
name = 'pwn-ckyan', | ||
version = '2.1.3', | ||
version = '2.1.4', | ||
author = 'Comentropy Ckyan', | ||
author_email = "[email protected]", | ||
description = "pwnScript", | ||
|
@@ -20,7 +20,7 @@ | |
], | ||
entry_points={ | ||
'console_scripts': [ | ||
'pwnScript=ckyan.pwnScript:args_parser' | ||
'pwnScript=ckyan.pwnScript.args_parser:args_init' | ||
], | ||
}, | ||
) | ||
|