Skip to content

Commit

Permalink
kraker-update
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzteph committed Nov 11, 2024
1 parent 4c0f219 commit 12adb6f
Show file tree
Hide file tree
Showing 11 changed files with 171 additions and 38 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "crackjs",
"name": "kraker-js",
"version": "1.0.0",
"main": "index.js",
"scripts": {
Expand Down
158 changes: 121 additions & 37 deletions tools/krakerjs/src/App.vue → tools/kraker-js/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,20 @@ const crackWorker = ref(null);
const useRules = ref(false);
const ruleUrl = ref('');
const wordlistUrl=ref('https://weakpass.com/api/v1/wordlists/rockyou.txt');
const mainTab = ref('hashes');
const attackTab = ref('files');
const wordlistFile = ref(null);
const wordlistName = ref('');
const rulesFile = ref(null);
const rulesName = ref('');
const benchmarkWorker = ref(null);
const isBenchmarkWorkerRunning = computed(() => {
Expand Down Expand Up @@ -49,16 +60,30 @@ const foundEntries = ref([]);
const crackWordlistOnline = () => {
const runCrackWorker = () => {
if (crackWorker.value) {
let shouldRestart = confirm("A worker is already running. Do you want to restart it?");
if (!shouldRestart) return;
stopCrackWorker();
}
if (!crackWorker.value) {
crackWorker.value = new Worker(new URL('./workers/wordlist.js', import.meta.url), { type: 'module' });
if(attackTab.value=="files")
crackWorker.value = new Worker(new URL('./workers/files.js', import.meta.url), { type: 'module' });
else if(attackTab.value=="online")
crackWorker.value = new Worker(new URL('./workers/online.js', import.meta.url), { type: 'module' });
else if(attackTab.value=="text")
crackWorker.value = new Worker(new URL('./workers/text.js', import.meta.url), { type: 'module' });
else
{
stopCrackWorker();
logMessage("undefined attackType="+attackTab.value);
return;
}
crackWorker.value.onmessage = (event) => {
if(event.data.type=="status")
Expand All @@ -82,14 +107,24 @@ const crackWordlistOnline = () => {
}
};
}
crackWorker.value.postMessage({
action: 'start',
useRules: useRules.value,
ruleUrl: ruleUrl.value,
wordlistUrl: wordlistUrl.value,
hashEntries: hashEntries.value,
selectedHashType:selectedHashType.value
});
if(attackTab.value=="online")
{
crackWorker.value.postMessage({ action: 'start', useRules: useRules.value, ruleUrl: ruleUrl.value, wordlistUrl: wordlistUrl.value, hashEntries: hashEntries.value, selectedHashType:selectedHashType.value});
}
else if(attackTab.value=="files")
{
crackWorker.value.postMessage({ action: 'start', useRules: useRules.value, wordlistFile: wordlistFile.value, rulesFile: rulesFile.value});
}
else
{
stopCrackWorker();
logMessage("undefined attackType="+attackTab.value);
return;
}
logMessage("crackWorker started");
Expand Down Expand Up @@ -134,6 +169,9 @@ const benchmarkRun = () => {
};
const stopCrackWorker = () => {
if (crackWorker!=null && crackWorker.value!=null) {
Expand Down Expand Up @@ -172,13 +210,24 @@ onBeforeUnmount(() => {
});
const fileSizeDisplay = computed(() => {
if (fileSize.value < 1024) return `${fileSize.value} bytes`;
if (fileSize.value < 1024 * 1024) return `${(fileSize.value / 1024).toFixed(2)} KB`;
return `${(fileSize.value / (1024 * 1024)).toFixed(2)} MB`;
});
function handleWordlistSelect(event) {
wordlistFile.value = event.target.files[0];
wordlistName.value = wordlistFile.value ? wordlistFile.value.name : '';
}
function handleRulesSelect(event) {
rulesFile.value = event.target.files[0];
rulesName.value = rulesFile.value ? rulesFile.value.name : '';
}
const mainTab = ref('hashes');
const attackTab = ref('text');
const changeMainTab = (tab) => {
mainTab.value = tab;
};
Expand Down Expand Up @@ -314,6 +363,13 @@ onBeforeUnmount(() => {
</div>
</div>
<div v-if="!isCrackWorkerRunning" class="control">
<button class="button is-link" @click="runCrackWorker">Crack</button>
</div>
<div v-if="isCrackWorkerRunning" class="control" id="button_stop">
<button class="button is-danger" @click="stopCrackWorker">Stop</button>
</div>
</div>
</div>
Expand All @@ -338,13 +394,62 @@ onBeforeUnmount(() => {
<div class="column">
<div class="tabs is-boxed">
<ul>
<li :class="{ 'is-active': attackTab === 'files' }"><a @click="changeAttackTab('files')">Files</a></li>
<li :class="{ 'is-active': attackTab === 'text' }"><a @click="changeAttackTab('text')">Text</a></li>
<li :class="{ 'is-active': attackTab === 'online' }" ><a @click="changeAttackTab('online')">Online</a></li>
</ul>
</div>
<div v-if="attackTab === 'files'">
<div class="field">
<label class="label">Wordlist file</label>
<div class="control">
<div class="file">
<label class="file-label">
<input class="file-input" type="file" @change="handleWordlistSelect" />
<span class="file-cta">
<span class="file-label" v-if="wordlistName">{{ wordlistName }}</span>
<span class="file-label" v-else> Choose a file… </span>
</span>
</label>
</div>
</div>
</div>
<div class="field">
<label class="checkbox">
<input type="checkbox" v-model="useRules">
Use Rules
</label>
</div>
<div class="field" v-if="useRules">
<label class="label">Rules file</label>
<div class="control">
<div class="file">
<label class="file-label">
<input class="file-input" type="file" @change="handleRulesSelect" />
<span class="file-cta">
<span class="file-label" v-if="ruleName">{{ ruleName }}</span>
<span class="file-label" v-else> Choose a file… </span>
</span>
</label>
</div>
</div>
</div>
</div>
<div v-if="attackTab === 'text'">
<div class="field">
Expand All @@ -358,25 +463,11 @@ onBeforeUnmount(() => {
<div class="columns">
<div class="column is-half">
Wordlist
<textarea class="textarea is-primary" id="passwords" rows="25" placeholder="Passwords">
!QAZxsw2
!root
0123456789
0392a0
0987654321
102030
10203040
112233
</textarea>
<textarea class="textarea is-primary" id="passwords" rows="25" placeholder="Passwords"></textarea>
</div>
<div class="column is-half">
Rules
<textarea class="textarea is-primary" id="rules" rows="25" placeholder="Rules">
:
c
u
C
</textarea>
<textarea class="textarea is-primary" id="rules" rows="25" placeholder="Rules"></textarea>
</div>
</div>
</div>
Expand Down Expand Up @@ -404,14 +495,7 @@ onBeforeUnmount(() => {
</div>
</div>
<div class="field is-grouped">
<div v-if="!isCrackWorkerRunning" class="control">
<button class="button is-link" @click="crackWordlistOnline">Crack</button>
</div>
<div v-if="isCrackWorkerRunning" class="control" id="button_stop">
<button class="button is-danger" @click="stopCrackWorker">Stop</button>
</div>
</div>
</div>
Expand Down
File renamed without changes.
49 changes: 49 additions & 0 deletions tools/kraker-js/src/workers/files.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import hashcat from 'crack-js';
self.onmessage = async (event) => {
if (event.data.action === 'start') {
console.log("START");

const wordlistFile = event.data.wordlistFile;
const useRules = event.data.useRules;
const rulesFile = event.data.wordlistFile;

let countLines=0;
postMessage({ type:"log", message: "wordlistFile:"+wordlistFile.name});


readChunk(wordlistFile,0,'');
console.log(countLines);


postMessage({ type:"status", status: "done"});

}
};

function readChunk(wordlistFile,offset, remainder) {
const chunkSize=64 * 1024;
console.log(wordlistFile.size);
console.log(wordlistFile.name);
if (offset >= wordlistFile.size) {
self.close();
return;
}

const blob = wordlistFile.slice(offset, offset + chunkSize);
const reader = new FileReader();

reader.onload = (event) => {
const text = remainder + event.target.result;
const lines = text.split('\n');
remainder = lines.pop();

lines.forEach((line) => {
console.log(line);
});

offset += chunkSize;
readChunk(wordlistFile,offset, remainder);
};

reader.readAsText(blob);
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 12adb6f

Please sign in to comment.