Skip to content

Commit 454340a

Browse files
committed
added script and web based
1 parent 90c874a commit 454340a

File tree

4 files changed

+16698
-1
lines changed

4 files changed

+16698
-1
lines changed

Web Based/gen node/node-generate.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import requests
2+
import json
3+
import os
4+
5+
url = "https://raw.githubusercontent.com/Jieyab89/OSINT-Cheat-sheet/refs/heads/main/README.md"
6+
7+
response = requests.get(url)
8+
data = response.text
9+
10+
json_file = "osint_data.json"
11+
if os.path.exists(json_file):
12+
with open(json_file, "r", encoding="utf-8") as f:
13+
try:
14+
existing_data = json.load(f)
15+
except json.JSONDecodeError:
16+
existing_data = []
17+
else:
18+
existing_data = []
19+
20+
existing_categories = {cat["category"]: cat for cat in existing_data}
21+
22+
new_categories = {}
23+
current_category = None
24+
25+
for line in data.split("\n"):
26+
line = line.strip()
27+
28+
if line.startswith("# "):
29+
current_category = line[2:].strip()
30+
if current_category not in new_categories:
31+
new_categories[current_category] = {"category": current_category, "items": []}
32+
33+
elif line.startswith("- [") and "](" in line:
34+
parts = line.split("[", 1)[1].split("](")
35+
name = parts[0].strip()
36+
link = parts[1].split(")")[0].strip()
37+
38+
if current_category:
39+
new_categories[current_category]["items"].append({"name": name, "url": link})
40+
41+
for category, new_data in new_categories.items():
42+
if category in existing_categories:
43+
existing_items = {item["name"] for item in existing_categories[category]["items"]}
44+
for new_item in new_data["items"]:
45+
if new_item["name"] not in existing_items:
46+
existing_categories[category]["items"].append(new_item)
47+
else:
48+
existing_categories[category] = new_data
49+
50+
with open(json_file, "w", encoding="utf-8") as f:
51+
json.dump(list(existing_categories.values()), f, indent=4, ensure_ascii=False)
52+
53+
print("Data updated: osint_data.json")

Web Based/index.html

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Jieyab89 OSINT Cheat Sheet</title>
7+
<script src="https://d3js.org/d3.v6.min.js"></script>
8+
<style>
9+
body {
10+
font-family: Arial, sans-serif;
11+
background-color: #121212;
12+
color: #ffffff;
13+
text-align: center;
14+
margin: 0;
15+
padding: 0;
16+
overflow: hidden;
17+
}
18+
#search {
19+
margin: 5px;
20+
padding: 8px;
21+
width: 85%;
22+
max-width: 400px;
23+
font-size: 16px;
24+
border-radius: 5px;
25+
border: none;
26+
}
27+
svg {
28+
width: 100vw;
29+
height: 100vh;
30+
}
31+
.node circle {
32+
stroke: #ffffff;
33+
stroke-width: 2px;
34+
cursor: pointer;
35+
}
36+
.link {
37+
stroke: #888;
38+
stroke-width: 1.5px;
39+
}
40+
text {
41+
font-size: 12px;
42+
fill: #ffffff;
43+
pointer-events: none;
44+
}
45+
</style>
46+
</head>
47+
<body>
48+
<h1>Jieyab89 OSINT Cheat Sheet</h1>
49+
<input type="text" id="search" placeholder="Search by Category Name">
50+
<svg></svg>
51+
<script>
52+
let allNodes = [], allLinks = [];
53+
54+
fetch()
55+
.then(response => response.json())
56+
.then(data => {
57+
allNodes = [];
58+
allLinks = [];
59+
const nodeMap = new Map();
60+
61+
data.forEach(category => {
62+
let catNode = { id: category.category, type: 'category' };
63+
allNodes.push(catNode);
64+
nodeMap.set(category.category, catNode);
65+
66+
category.items.forEach(item => {
67+
let toolNode = { id: item.name, url: item.url, type: 'tool' };
68+
allNodes.push(toolNode);
69+
allLinks.push({ source: category.category, target: item.name });
70+
nodeMap.set(item.name, toolNode);
71+
});
72+
});
73+
updateGraph(allNodes, allLinks);
74+
})
75+
.catch(error => console.error("Error loading JSON:", error));
76+
77+
function updateGraph(nodes, links) {
78+
d3.select("svg").selectAll("*").remove();
79+
80+
const width = window.innerWidth;
81+
const height = window.innerHeight;
82+
83+
const svg = d3.select("svg")
84+
.attr("width", width)
85+
.attr("height", height)
86+
.call(d3.zoom().on("zoom", (event) => {
87+
svgGroup.attr("transform", event.transform);
88+
}));
89+
90+
let svgGroup = svg.append("g");
91+
92+
const simulation = d3.forceSimulation(nodes)
93+
.force("link", d3.forceLink(links).id(d => d.id).distance(150))
94+
.force("charge", d3.forceManyBody().strength(-300))
95+
.force("center", d3.forceCenter(width / 2, height / 2))
96+
.force("collision", d3.forceCollide().radius(40));
97+
98+
const link = svgGroup.append("g")
99+
.selectAll("line")
100+
.data(links)
101+
.enter().append("line")
102+
.attr("class", "link");
103+
104+
const node = svgGroup.append("g")
105+
.selectAll("g")
106+
.data(nodes)
107+
.enter().append("g");
108+
109+
node.append("circle")
110+
.attr("r", d => d.type === 'category' ? 12 : 8)
111+
.attr("fill", d => d.type === 'category' ? "#FF5733" : "#1E90FF")
112+
.call(d3.drag()
113+
.on("start", dragstarted)
114+
.on("drag", dragged)
115+
.on("end", dragended));
116+
117+
node.append("text")
118+
.attr("dy", -15)
119+
.attr("text-anchor", "middle")
120+
.text(d => d.id);
121+
122+
node.on("click", (event, d) => {
123+
if (d.url) {
124+
window.open(d.url, "_blank");
125+
}
126+
});
127+
128+
simulation.on("tick", () => {
129+
link
130+
.attr("x1", d => d.source.x)
131+
.attr("y1", d => d.source.y)
132+
.attr("x2", d => d.target.x)
133+
.attr("y2", d => d.target.y);
134+
135+
node
136+
.attr("transform", d => `translate(${d.x},${d.y})`);
137+
});
138+
}
139+
140+
document.getElementById("search").addEventListener("input", function() {
141+
const searchTerm = this.value.toLowerCase();
142+
if (searchTerm === "") {
143+
updateGraph(allNodes, allLinks);
144+
return;
145+
}
146+
147+
const filteredNodes = [];
148+
const filteredLinks = [];
149+
150+
allNodes.forEach(node => {
151+
if (node.type === 'category' && node.id.toLowerCase().includes(searchTerm)) {
152+
filteredNodes.push(node);
153+
allLinks.forEach(link => {
154+
if (link.source.id === node.id) {
155+
filteredNodes.push(link.target);
156+
filteredLinks.push(link);
157+
}
158+
});
159+
}
160+
});
161+
162+
updateGraph(filteredNodes, filteredLinks);
163+
});
164+
165+
function dragstarted(event, d) {
166+
if (!event.active) event.sourceEvent.stopPropagation();
167+
d.fx = d.x;
168+
d.fy = d.y;
169+
}
170+
171+
function dragged(event, d) {
172+
d.fx = event.x;
173+
d.fy = event.y;
174+
}
175+
176+
function dragended(event, d) {
177+
d.fx = null;
178+
d.fy = null;
179+
}
180+
</script>
181+
</body>
182+
</html>

0 commit comments

Comments
 (0)