Due to the requirements of my work, I needed to design an open software system, and immediately thought of the Python language. As a result, I designed a simple and easily extensible plugin system.
if choice == "1": plugin_name = input("Please input the name of plugin: ") manager.load_plugin(plugin_name)
elif choice == "2": manager.run_plugins()
elif choice == "3": break
Then, you create a directory named ‘plugins.’ In this directory, you can add your plugin, which must define a class named ‘MyPlugin’ and must have a function named ‘run’. Here is the simple code:
1 2 3 4 5 6 7
#my_plugin
classMyPlugin: def__init__(self): pass defrun(self): print("MyPlugin is running")
The following is the running process:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
1. Add Plugin 2. Run Plugin 3. Quit Your Select: 1 Please input the name of plugin: my_plugin plugin my_plugin loaded. 1. Add Plugin 2. Run Plugin 3. Quit Your Select: 2 MyPlugin is running 1. Add Plugin 2. Run Plugin 3. Quit Your Select: 3 PS C:\Users\xxx\Desktop\yyy\plugin-system>
You can use this model to design a big and an opened software system.
pop esi ; Pop '/bin/sh' from the stack into esi xor eax, eax ; Set eax to NULL mov byte [esi + 7], al ; Null-terminate '/bin/sh' using the low byte of eax lea ebx, [esi] ; Load the address of '/bin/sh' into ebx mov dword [esi + 8], ebx lea ecx, [esi + 8] ; Load the address of the argv array into ecx mov dword [esi + 12], eax lea edx, [esi + 12] ; Load the address of the NULL terminator into edx mov al, 0x0b ; Set al to 0x0b, the system call number for execve int 0x80 ; Trigger the syscall
callShellcode:
call shellcode db '/bin/sh'
After saving this code to a file named “shellx.asm,” you need to compile it using NASM to obtain the hexadecimal representation of the code. Use the following commands:
This will generate a “shellx” file. However, it’s not executable yet. You’ll need to use the “objdump” command to extract the hexadecimal code. You can use a Bash script like this:
1 2 3 4
for i in $(objdump -d "$1" | tr'\t'' ' | tr' ''\n' | egrep '^[0-9a-f]{2}$'); do echo -n "\x$i" done echo -e "\n"
To validate your assembly code, you’ll need a C program as follows:
The first ‘d’ means this is a directory. The first part ‘rwx’ indicates that the user who owns it has read/write/execute permissions, and the second part ‘rwx’ indicates that other users in the file’s group have read/write/execute permissions. The third part ‘r-x’ indicates that other users not in the file’s group have read/-/execute permissions.
By the way, we often see commands like this: ‘chmod 777 ./rootfs’. This means the first part, where the rwx bits are all 1, indicates that this directory has read, write, and execute permissions for all users.”
Performing relevant hashing operations is an essential skill in penetration testing. Here is a compilation of code snippets for common hash implementations in Python.
md5 :
1 2 3 4 5 6
import hashlib
mystring = input('Enter String to hash: ') # Assumes the default UTF-8 hash_object = hashlib.md5(mystring.encode()) print(hash_object.hexdigest())
The “information_schema“ is a system database in MySQL that contains metadata information about databases, tables, columns, indexes, users, permissions, and more within the MySQL server. It serves as an interface for querying metadata information in MySQL. This information is stored in tabular form within tables in the “information_schema” database, and users can retrieve metadata information by using SQL statements to query these tables.
Here are some common tables in the ‘information_schema’ database:
SCHEMATA: Stores information about all databases, including database names, character sets, etc.
TABLES: Stores information about all tables, including table names, table types, engines, etc.
COLUMNS: Stores information about all columns, including column names, column data types, column constraints, etc.
STATISTICS: Stores information about all indexes, including index names, index types, the table where the index is located, index columns, etc.
USER_PRIVILEGES: Stores information about user privileges, including user accounts, permissions, etc.
By querying the tables in the information_schema database, you can obtain information about various aspects of databases, tables, columns, indexes, users, and permissions. This is very helpful for database management and maintenance.
Next, let’s take a look at an example of finding key information through the information_schema database:
Query information about the current user:
1
SELECT current_user();
Query information about the user for the current session:
1
SELECT session_user();
Get the path of the database:
1
SELECT @@datadir;
Get the installation path of MySQL:
1
select @@basedir;
Retrieve information about the operating system version:
Recently, in a project, there was a need to transmit custom data using QAction::setData. I’ve searched online for a lot of information, but it’s all a bit vague, and none of them hit the mark. Some even provide solutions that completely contradict Qt’s principles. Below is an example code I wrote:
Custom data: Here, taking a custom class as an example, the code is as follows:
In the end, it’s all about the representation of floating-point numbers. According to the IEEE standard, the first bit is the sign bit, the next 8 bits represent the exponent, and the remaining 23 bits are the mantissa. Considering that it’s little-endian storage, the value of the number 00 C0 2B 45 is 452BC000, which is:
1
0100 0101 0010 1011 1100 0000 0000 0000
The first bit is 0, indicating it’s a positive number. The next 8 bits, which is 10001010, 8A, in decimal, is 138. 138 - 127 = 11, indicating the exponent is 11 bits. And the remaining 23 bits have the value:
1
010 1011 1100 0000 0000 0000
The leading bit, with the omitted 1, has a value of:
1
1010 1011 1100 0000 0000 0000
Above 11 bits for the exponent indicate that the position of the decimal point is:
1
1010 1011 1100 . 0000 0000 0000
Converting to hexadecimal, it’s ABC.000. Converting to decimal, it’s 2748.00000000.
Some time ago, a friend asked me to help reverse engineer something, extract its code, save it as an assembly file, and compile and run it in VC (Visual C++).