-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathreverse.html
More file actions
246 lines (187 loc) · 5.19 KB
/
reverse.html
File metadata and controls
246 lines (187 loc) · 5.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>github email getter (minimal)</title>
<style>
body {
background: #0d1117;
color: #c9d1d9;
font-family: monospace;
padding: 20px;
}
h1 {
margin-bottom: 10px;
}
input, button {
background: #161b22;
color: #c9d1d9;
border: 1px solid #30363d;
padding: 10px;
font-family: monospace;
}
button {
cursor: pointer;
}
button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.section {
margin-top: 30px;
padding-top: 20px;
border-top: 1px solid #30363d;
}
.output {
margin-top: 15px;
white-space: pre-wrap;
background: #161b22;
padding: 15px;
border: 1px solid #30363d;
}
.error {
color: #ff7b72;
}
.success {
color: #3fb950;
}
</style>
</head>
<body>
<h1>github email getter</h1>
<p>minimal · dark · public github osint</p>
<div class="section">
<h2>username → email</h2>
<form id="forwardForm">
<input id="usernameInput" placeholder="github username or profile url" />
<button type="submit">search</button>
</form>
<div id="forwardOutput" class="output">waiting…</div>
</div>
<div class="section">
<h2>email → accounts</h2>
<form id="reverseForm">
<input id="emailInput" placeholder="email address" />
<button type="submit">search</button>
</form>
<div id="reverseOutput" class="output">waiting…</div>
</div>
<script>
const GITHUB_API = "https://api.github.com";
const RESULTS_PER_PAGE = 100;
function isEmail(value) {
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
}
function isNoReply(email) {
return email.endsWith("@users.noreply.github.com");
}
function extractUsername(input) {
if (input.includes("github.com")) {
return input.split("github.com/")[1].split("/")[0];
}
return input;
}
function setOutput(el, text, type = "") {
el.className = "output " + type;
el.textContent = text;
}
document.getElementById("forwardForm").addEventListener("submit", async e => {
e.preventDefault();
const output = document.getElementById("forwardOutput");
const rawInput = document.getElementById("usernameInput").value.trim();
if (!rawInput) {
return setOutput(output, "missing username", "error");
}
const username = extractUsername(rawInput);
setOutput(output, "searching…");
try {
/* ---- Fetch user profile ---- */
const userRes = await fetch(`${GITHUB_API}/users/${username}`);
if (!userRes.ok) throw userRes;
const user = await userRes.json();
if (user.email && isEmail(user.email) && !isNoReply(user.email)) {
return setOutput(
output,
`email found (profile):\n${user.email}`,
"success"
);
}
const repoRes = await fetch(
`${GITHUB_API}/users/${username}/repos?per_page=${RESULTS_PER_PAGE}`
);
if (!repoRes.ok) throw repoRes;
const repos = await repoRes.json();
for (const repo of repos) {
const commitsUrl = repo.commits_url.replace("{/sha}", "") + "?per_page=10";
const commitsRes = await fetch(commitsUrl);
if (!commitsRes.ok) continue;
const commits = await commitsRes.json();
for (const c of commits) {
const email = c.commit?.author?.email;
const author = c.author?.login;
if (
author?.toLowerCase() === username.toLowerCase() &&
isEmail(email) &&
!isNoReply(email)
) {
return setOutput(
output,
`email found (commit):\n${email}\nrepo: ${repo.name}`,
"success"
);
}
}
}
setOutput(output, "no public email found", "error");
} catch (err) {
if (err.status === 404) {
setOutput(output, "user not found", "error");
} else if (err.status === 403) {
setOutput(output, "github rate limit exceeded", "error");
} else {
setOutput(output, "unexpected error", "error");
}
}
});
document.getElementById("reverseForm").addEventListener("submit", async e => {
e.preventDefault();
const output = document.getElementById("reverseOutput");
const email = document.getElementById("emailInput").value.trim().toLowerCase();
if (!isEmail(email)) {
return setOutput(output, "invalid email", "error");
}
if (isNoReply(email)) {
return setOutput(output, "noreply emails cannot be traced", "error");
}
setOutput(output, "searching…");
try {
const res = await fetch(
`${GITHUB_API}/search/commits?q=author-email:${encodeURIComponent(email)}`
);
if (!res.ok) throw res;
const data = await res.json();
const users = new Set();
data.items?.forEach(item => {
if (item.author?.login) {
users.add(item.author.login);
}
});
if (users.size === 0) {
return setOutput(output, "no accounts found", "error");
}
setOutput(
output,
`accounts found:\n\n${[...users].join("\n")}`,
"success"
);
} catch (err) {
if (err.status === 403) {
setOutput(output, "github rate limit exceeded", "error");
} else {
setOutput(output, "unexpected error", "error");
}
}
});
</script>
</body>
</html>