Commit 2e97bc98 authored by Sigfried Seldeslachts's avatar Sigfried Seldeslachts
Browse files

Merge branch 'master' into 'master'

Scripts

See merge request !1
parents 23a231b5 c10329c7
## SCRIPTS
This directory contains scripts to ease the calculations for little endian and disk layout in FAT16.
You probably will need to allow these in your firewall, because they will probably be flagged as a Trojan or something.
## Disclaimer
The scripts in this directory may contain errors. Please do not rely on this and always check it for yourself!
### diskLayout
Calulates the:
- Boot sector
- Size of Cluster in Bytes
- First Fat in Bytes
- Size of Fat in Bytes
- Root Directory Address
- Root Directory Size in Bytes
- Data Region Address
- Total Size of FAT16 Volume in Bytes
based on:
- Bytes per sector
- Sectors per Cluster
- Reserved Sectors from Start of the Volume
- Number of Possible Root Entries
- Small Number of Sectors
- Sectors per FAT16
with ***bootsector = 00100000***
### little endian
Reverts the input little endian to normal decimal output.
Keeps looping until empty input for ease of use.
def main():
bootsectorInput = input("Bootsector (leeg voor std 0x100000)? ")
if len(bootsectorInput)==8:
if int(bootsectorInput,16):
bootsector = bootsectorInput
else:
bootsector = "0x100000"
else:
bootsector = "0x100000"
bytes_per_sector = int(input("Bytes per sector? "))
sectors_per_cluster = int(input("Sectors per cluster? "))
reserved_sectors_from_the_start_of_the_volume = int(input("Reserved sectors from the start of the volume? "))
number_possible_root_entries = int(input("Number possible root entries? "))
small_numbers_of_sectors = int(input("Small numbers of sectors? "))
sectors_per_fat = int(input("Sectors per FAT? "))
fat_count = int(input("How many FAT's? "))
#Disk Layout
size_of_clusters_in_bytes = bytes_per_sector * sectors_per_cluster
first_fat_address = hex((bytes_per_sector * reserved_sectors_from_the_start_of_the_volume) + int(bootsector, 16))
size_of_fat_in_bytes = bytes_per_sector * sectors_per_fat
root_directory_address = hex(int(first_fat_address, 16) + size_of_fat_in_bytes * fat_count)
root_directory_size_in_bytes = number_possible_root_entries * 32
data_region_address = hex(int(root_directory_address, 16) + root_directory_size_in_bytes)
total_size_of_fat16_volume_in_bytes = small_numbers_of_sectors * bytes_per_sector
print('-------- Results --------')
print('Boot Sector : ', bootsector)
print('Size of Cluster in Bytes : ', size_of_clusters_in_bytes)
print('First FAT Address : ', first_fat_address)
print('Size of FAT in Bytes : ', size_of_fat_in_bytes)
print('Root Directory Address : ', root_directory_address)
print('Root Directory Size in Bytes : ', root_directory_size_in_bytes)
print('Data Region Address : ', data_region_address)
print('Total Size of FAT16 Volume in Bytes : ', total_size_of_fat16_volume_in_bytes)
print("Doe eerst de boot sector oefening, die waarde heb je nodig om de disk layout te berekenen via deze tool.")
input("Press any key to continue")
run = True
while (run):
main()
vraag = input("continue?(y/n): ")
if(vraag != "y" and vraag != "Y"):
run = False
\ No newline at end of file
import re
import sys
def main(endian):
if(len(endian)==0):
exit()
number = "".join(str(endian).split())
number = re.sub('([\da-f]{2})',r'.\1',number)
number = number.split(".")
number.reverse()
number = "".join(number)
print(int(number,16))
while(True):
print("Te converteren waarde van little endian hex naar decimaal")
endian = input("little endian hexwaarde (leeg om te stoppen) = ")
main(endian)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment