new script
This commit is contained in:
parent
3b0d80b484
commit
109fe2dbd2
7 changed files with 113 additions and 1 deletions
3
Readme.md
Normal file → Executable file
3
Readme.md
Normal file → Executable file
|
@ -18,6 +18,9 @@ This is a small bash script that should be piped through ```unzip -l file.zip```
|
||||||
### 5. `packet.py`
|
### 5. `packet.py`
|
||||||
A small packet I use for testing. ```scapy``` needed.
|
A small packet I use for testing. ```scapy``` needed.
|
||||||
|
|
||||||
|
### 6. `cpp-project-gen.py`
|
||||||
|
A small script to generate a c++ project structure.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
No installation is necessary for these scripts. They are standalone Python scripts that can be run from the command line. Ensure you have Python installed on your system, navigate to the directory containing these scripts, and execute them with Python. For example:
|
No installation is necessary for these scripts. They are standalone Python scripts that can be run from the command line. Ensure you have Python installed on your system, navigate to the directory containing these scripts, and execute them with Python. For example:
|
||||||
|
|
||||||
|
|
109
cpp-project-gen.py
Normal file
109
cpp-project-gen.py
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
def create_file(path, content=""):
|
||||||
|
with open(path, 'w') as file:
|
||||||
|
file.write(content)
|
||||||
|
|
||||||
|
def create_cpp_project_structure(project_name):
|
||||||
|
# Define the folder structure
|
||||||
|
folders = [
|
||||||
|
f"{project_name}/include/{project_name}",
|
||||||
|
f"{project_name}/src",
|
||||||
|
f"{project_name}/tests",
|
||||||
|
f"{project_name}/third_party",
|
||||||
|
f"{project_name}/build",
|
||||||
|
f"{project_name}/docs"
|
||||||
|
]
|
||||||
|
|
||||||
|
# Create the folders
|
||||||
|
for folder in folders:
|
||||||
|
os.makedirs(folder, exist_ok=True)
|
||||||
|
|
||||||
|
# Define the content for CMakeLists.txt
|
||||||
|
cmake_content = f"""cmake_minimum_required(VERSION 3.10)
|
||||||
|
project({project_name} VERSION 1.0)
|
||||||
|
|
||||||
|
# Specify C++ standard
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||||
|
|
||||||
|
# Add include directory
|
||||||
|
include_directories(include)
|
||||||
|
|
||||||
|
# Add executable
|
||||||
|
add_executable({project_name} src/main.cpp src/example.cpp)
|
||||||
|
|
||||||
|
# Add library (if you have one)
|
||||||
|
add_library(example src/example.cpp)
|
||||||
|
target_include_directories(example PUBLIC include)
|
||||||
|
|
||||||
|
# Link library to executable
|
||||||
|
target_link_libraries({project_name} example)
|
||||||
|
|
||||||
|
# Add tests
|
||||||
|
enable_testing()
|
||||||
|
add_subdirectory(tests)
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Define the content for tests/CMakeLists.txt
|
||||||
|
tests_cmake_content = """add_executable(runTests test_example.cpp)
|
||||||
|
target_link_libraries(runTests gtest gtest_main)
|
||||||
|
add_test(NAME ExampleTest COMMAND runTests)
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Define the content for main.cpp
|
||||||
|
main_cpp_content = """#include <iostream>
|
||||||
|
int main() {
|
||||||
|
std::cout << "Hello, World!" << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Define the content for example.h
|
||||||
|
example_h_content = f"""#ifndef {project_name.upper()}_EXAMPLE_H
|
||||||
|
#define {project_name.upper()}_EXAMPLE_H
|
||||||
|
|
||||||
|
void exampleFunction();
|
||||||
|
|
||||||
|
#endif // {project_name.upper()}_EXAMPLE_H
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Define the content for example.cpp
|
||||||
|
example_cpp_content = f"""#include "{project_name}/example.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
void exampleFunction() {{
|
||||||
|
std::cout << "This is an example function." << std::endl;
|
||||||
|
}}
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Define the content for test_example.cpp
|
||||||
|
test_example_content = """#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
TEST(ExampleTest, BasicAssertions) {
|
||||||
|
// Expect two strings to be equal.
|
||||||
|
EXPECT_EQ("hello", "hello");
|
||||||
|
// Expect equality.
|
||||||
|
EXPECT_EQ(7 * 6, 42);
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Define the content for README.md
|
||||||
|
readme_content = f"""# {project_name}
|
||||||
|
This is the {project_name} project.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Create files with the defined content
|
||||||
|
create_file(f"{project_name}/CMakeLists.txt", cmake_content)
|
||||||
|
create_file(f"{project_name}/tests/CMakeLists.txt", tests_cmake_content)
|
||||||
|
create_file(f"{project_name}/src/main.cpp", main_cpp_content)
|
||||||
|
create_file(f"{project_name}/include/{project_name}/example.h", example_h_content)
|
||||||
|
create_file(f"{project_name}/src/example.cpp", example_cpp_content)
|
||||||
|
create_file(f"{project_name}/tests/test_example.cpp", test_example_content)
|
||||||
|
create_file(f"{project_name}/README.md", readme_content)
|
||||||
|
|
||||||
|
print(f"C++ project '{project_name}' structure generated successfully.")
|
||||||
|
|
||||||
|
# Prompt the user for a project name
|
||||||
|
project_name = input("Enter the project name: ")
|
||||||
|
create_cpp_project_structure(project_name)
|
2
packet.py
Normal file → Executable file
2
packet.py
Normal file → Executable file
|
@ -1,7 +1,7 @@
|
||||||
from scapy.all import sendp, Ether, IP, UDP
|
from scapy.all import sendp, Ether, IP, UDP
|
||||||
|
|
||||||
destination_ip = '255.255.255.255'
|
destination_ip = '255.255.255.255'
|
||||||
source_ip = '192.168.1.121'
|
source_ip = '192.168.100.223'
|
||||||
source_mac = '8c:16:45:68:54:80'
|
source_mac = '8c:16:45:68:54:80'
|
||||||
destination_mac = 'ff:ff:ff:ff:ff:ff' # Broadcast MAC address
|
destination_mac = 'ff:ff:ff:ff:ff:ff' # Broadcast MAC address
|
||||||
source_port = 14236
|
source_port = 14236
|
||||||
|
|
0
sizegetter.py
Normal file → Executable file
0
sizegetter.py
Normal file → Executable file
0
unzipdir.py
Normal file → Executable file
0
unzipdir.py
Normal file → Executable file
0
zipremove.py
Normal file → Executable file
0
zipremove.py
Normal file → Executable file
0
zipsize
Normal file → Executable file
0
zipsize
Normal file → Executable file
Loading…
Reference in a new issue