Skip to content

Instantly share code, notes, and snippets.

@roycewilliams
Created December 21, 2016 05:50
Show Gist options
  • Save roycewilliams/049797dd95d4336dea70a2d319dfe8a3 to your computer and use it in GitHub Desktop.
Save roycewilliams/049797dd95d4336dea70a2d319dfe8a3 to your computer and use it in GitHub Desktop.
hexhosts.c
# Via: https://up1ink.tumblr.com/post/132370869368/bruteforcing-knownhosts-file-with-hashcat
# Credit: https://github.com/persona5/hexhosts
#define _GNU_SOURCE
#include ""
#include ""
int main(void) {
FILE *fp;
char *line = NULL;
char *pch = NULL;
char *pch2 = NULL;
unsigned char b64[24];
size_t len = 0;
ssize_t read;
fp = fopen("known_hosts", "r");
if (fp == NULL)
return 1;
while ((read = getline(&line, &len, fp)) != -1) {
pch=strtok(line+3," ");
pch=strtok(pch,"|");
pch2=strtok(NULL,"|");
__b64_pton(pch2,b64,sizeof(b64));
for (int i=0; i<20; i++) {
printf("%02x", b64[i]);
}
printf(":");
__b64_pton(pch,b64,sizeof(b64));
for (int i=0; i<20; i++) {
printf("%02x", b64[i]);
}
printf("n");
}
return 0;
}
# root@neo:~/.ssh# gcc hexhosts.c -lresolv -w -o hexhosts
# root@neo:~/.ssh# ./hexhosts
# a7453898831af52ada58c964832f6a36f04b9927:2be1fc63b56a3f49c6c25e61beeb0887bf5c4e9d
# root@neo:~/.ssh#
# GEt ipv4.hcmask
# http://pastebin.com/4HQ6C8gG
./hashcat-cli64.bin -a 3 -m 160 hash.txt ipv4.hcmask --hex-salt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment