cxwcxw commited on
Commit
fa37bfd
·
verified ·
1 Parent(s): 64bffb3

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +117 -5
  2. app.py +69 -0
  3. requirements.txt +28 -0
README.md CHANGED
@@ -1,12 +1,124 @@
1
  ---
2
  title: WhiteRabbitNeo
3
- emoji: 📉
4
  colorFrom: green
5
- colorTo: pink
6
  sdk: gradio
7
- sdk_version: 6.5.1
8
  app_file: app.py
9
- pinned: false
 
 
 
10
  ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  title: WhiteRabbitNeo
3
+ emoji: 💬
4
  colorFrom: green
5
+ colorTo: purple
6
  sdk: gradio
7
+ sdk_version: 5.9.1
8
  app_file: app.py
9
+ pinned: true
10
+ license: mit
11
+ thumbnail: >-
12
+ https://cdn-uploads.huggingface.co/production/uploads/64fbe312dcc5ce730e763dc6/VWduEhDSRJXeSqhUzYwCt.png
13
  ---
14
 
15
+ ## RabbitRedux: A Specialized Cybersecurity Code Classifier
16
+ **RabbitRedux** is an AI-powered model designed to classify and analyze code snippets, with a focus on cybersecurity applications like penetration testing, ransomware analysis, and security automation. Built upon the WhiteRabbitNeo/Llama-3.1-WhiteRabbitNeo-2-70B model, RabbitRedux is specialized for cybersecurity and offers high accuracy in analyzing and categorizing both general and cybersecurity-related code functions.
17
+
18
+
19
+ **Key Features**
20
+ - Penetration Testing Support: Assists in reconnaissance, enumeration, and task automation during penetration testing.
21
+ - Ransomware Analysis: Tracks and analyzes ransomware trends, providing actionable insights into emerging threats.
22
+ - Code Classification: Efficiently classifies code in general programming and cybersecurity-specific contexts.
23
+ - Adaptive Learning: Utilizes adapter transformers for modular training, making it flexible for quick adaptations to different tasks.
24
+
25
+ **Datasets Used**
26
+ RabbitRedux leverages a range of datasets focused on both general and cybersecurity-specific tasks:
27
+
28
+ - Canstralian/Wordlists: A collection of cybersecurity-related wordlists for improved analysis.
29
+ - Canstralian/CyberExploitDB: A database of known cybersecurity exploits for model training.
30
+ - Canstralian/pentesting_dataset: A dataset containing pentesting-specific code snippets and functions.
31
+ - Canstralian/ShellCommands: A dataset dedicated to shell commands commonly used in security operations.
32
+
33
+ ## Model Details
34
+ **Developer:** Canstralian
35
+ **Base Model:** WhiteRabbitNeo/Llama-3.1-WhiteRabbitNeo-2-70B, replit/replit-code-v1_5-3b
36
+ **Library:** Adapter Transformers
37
+ **License:** MIT License
38
+ **Metrics:** Precision, Recall, F1 Score
39
+ **Evaluation:** Evaluated for code classification tasks with an emphasis on cybersecurity
40
+ **Tags:** code, text-generation-inference, security, cybersecurity
41
+
42
+ ## Usage
43
+ To use **RabbitRedux** for code classification, simply load the model and apply it for your cybersecurity tasks:
44
+
45
+ ```python
46
+ Copy code
47
+ from adapters import AutoAdapterModel
48
+
49
+ # Load the base model and RabbitRedux adapter
50
+ model = AutoAdapterModel.from_pretrained("replit/replit-code-v1_5-3b")
51
+ model.load_adapter("Canstralian/RabbitRedux", set_active=True)
52
+
53
+ # Use the model for classification tasks
54
+ predictions = model.predict(["Your code snippet here"])
55
+ Example Use Case
56
+ This model is perfect for tasks such as:
57
+
58
+ Classifying code snippets related to penetration testing.
59
+ Analyzing code related to security vulnerabilities or exploits.
60
+ Automatically categorizing code used in ransomware analysis.
61
+ Example:
62
+ python
63
+ Copy code
64
+ code_snippet = """import os
65
+ # Command to start a reverse shell
66
+ os.system('nc -lvp 4444')"""
67
+
68
+ predictions = model.predict([code_snippet])
69
+ print(predictions) # Output: ['Reverse Shell', 'Penetration Testing']
70
+ ```
71
+
72
+ ## Installation
73
+ **Install dependencies:**
74
+
75
+ ```bash
76
+ pip install transformers
77
+ pip install git+https://github.com/canstralian/RabbitRedux.git
78
+ ```
79
+
80
+ **Load the model:**
81
+
82
+ ```python
83
+ from adapters import AutoAdapterModel
84
+
85
+ model = AutoAdapterModel.from_pretrained("replit/replit-code-v1_5-3b")
86
+ model.load_adapter("Canstralian/RabbitRedux", set_active=True)
87
+ ```
88
+
89
+ ### Evaluation Metrics
90
+ RabbitRedux has been evaluated on code classification tasks using the following metrics:
91
+
92
+ - Precision: 0.95
93
+ - Recall: 0.92
94
+ - F1 Score: 0.93
95
+
96
+ These metrics indicate high accuracy in classifying code in the cybersecurity domain.
97
+
98
+ ## Contributions
99
+ **RabbitRedux** is an open-source project, and contributions are welcome! You can contribute by forking the repository, submitting pull requests, or sharing ideas for improvement.
100
+
101
+ ### GitHub Repository: RabbitRedux on GitHub
102
+ ### Issues & Feedback: Feel free to open issues or submit feedback directly through the repository.
103
+
104
+ ## Citation
105
+ If you use RabbitRedux in your work or research, please cite it as follows:
106
+
107
+ ### BibTeX:
108
+
109
+ ```bibtex
110
+ @misc{canstralian2024rabbitredux,
111
+ author = {Canstralian},
112
+ title = {RabbitRedux: A Model for Code Classification in Cybersecurity},
113
+ year = {2024},
114
+ url = {https://github.com/canstralian/RabbitRedux},
115
+ }
116
+ APA: Canstralian. (2024). RabbitRedux: A Model for Code Classification in Cybersecurity. Retrieved from https://github.com/canstralian/RabbitRedux
117
+ ```
118
+
119
+ ## License
120
+ RabbitRedux is licensed under the MIT License. See LICENSE for more details.
121
+
122
+ ## Contact
123
+ For more information or to get in touch with the developers, please visit Canstralian's GitHub or reach out through the repository issues page.
124
+
app.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from huggingface_hub import InferenceClient
3
+
4
+ # Initialize the InferenceClient with the specified model
5
+ client = InferenceClient("WhiteRabbitNeo/Llama-3.1-WhiteRabbitNeo-2-70B")
6
+
7
+ def respond(
8
+ message,
9
+ history: list[tuple[str, str]],
10
+ system_message,
11
+ max_tokens,
12
+ temperature,
13
+ top_p,
14
+ ):
15
+ messages = [{"role": "system", "content": system_message}]
16
+
17
+ for val in history:
18
+ if val[0]:
19
+ messages.append({"role": "user", "content": val[0]})
20
+ if val[1]:
21
+ messages.append({"role": "assistant", "content": val[1]})
22
+
23
+ messages.append({"role": "user", "content": message})
24
+
25
+ response = ""
26
+
27
+ try:
28
+ for message in client.chat_completion(
29
+ messages,
30
+ max_tokens=max_tokens,
31
+ stream=True,
32
+ temperature=temperature,
33
+ top_p=top_p,
34
+ ):
35
+ token = message['choices'][0]['delta']['content']
36
+ response += token
37
+ yield response
38
+ except Exception as e:
39
+ yield f"An error occurred: {str(e)}"
40
+
41
+ # Define the system message with a cybersecurity focus
42
+ system_message = (
43
+ "You are a cybersecurity expert chatbot, providing assistance on penetration testing, ransomware analysis, and code classification. "
44
+ "Your responses should be concise, accurate, and tailored to cybersecurity professionals."
45
+ )
46
+
47
+ # Create the Gradio interface with dark/light mode toggle
48
+ demo = gr.Interface(
49
+ fn=respond,
50
+ inputs=[
51
+ gr.Textbox(value=system_message, label="System Message"),
52
+ gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max New Tokens"),
53
+ gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
54
+ gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (Nucleus Sampling)"),
55
+ gr.Checkbox(label="Dark Mode", value=False), # Dark mode toggle
56
+ ],
57
+ outputs=[gr.Textbox()],
58
+ theme="dark", # Default theme
59
+ )
60
+
61
+ def toggle_theme(dark_mode):
62
+ """Toggle between dark and light themes based on user input."""
63
+ return "dark" if dark_mode else "light"
64
+
65
+ # Update the theme based on the checkbox value
66
+ demo.change(fn=toggle_theme, inputs=[demo.inputs[4]], outputs=[demo])
67
+
68
+ if __name__ == "__main__":
69
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ gradio>=5.9.1
2
+ huggingface_hub>=0.25.1
3
+ aiofiles>=22.0,<24.0
4
+ anyio>=3.0,<5.0
5
+ fastapi>=0.115.2,<1.0
6
+ ffmpy
7
+ gradio_client==1.5.2
8
+ httpx>=0.24.1
9
+ Jinja2<4.0
10
+ markupsafe~=2.0
11
+ numpy>=1.0,<3.0
12
+ orjson~=3.0
13
+ packaging
14
+ pandas>=1.0,<3.0
15
+ pillow>=8.0,<12.0
16
+ pydantic>=2.0
17
+ python-multipart>=0.0.18
18
+ pydub
19
+ pyyaml>=5.0,<7.0
20
+ ruff>=0.2.2; sys.platform != 'emscripten'
21
+ safehttpx>=0.1.6,<0.2.0
22
+ semantic_version~=2.0
23
+ starlette>=0.40.0,<1.0; sys.platform != 'emscripten'
24
+ tomlkit>=0.12.0,<0.14.0
25
+ typer>=0.12,<1.0; sys.platform != 'emscripten'
26
+ typing_extensions~=4.0
27
+ urllib3~=2.0; sys.platform == 'emscripten'
28
+ uvicorn>=0.14.0; sys.platform != 'emscripten'