diff --git a/.github/workflows/analyze-powershell.yml b/.github/workflows/analyze-powershell.yml new file mode 100644 index 0000000..97d6b06 --- /dev/null +++ b/.github/workflows/analyze-powershell.yml @@ -0,0 +1,34 @@ +name: PSScriptAnalyzer + +on: + push: + branches: [ "main", "GPU-MD5-Crack" ] + pull_request: + branches: [ "main", "GPU-MD5-Crack" ] + +permissions: + contents: write + +jobs: + build: + permissions: + contents: write # for actions/checkout to fetch code + security-events: write # for github/codeql-action/upload-sarif to upload SARIF results + actions: write # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status + name: PSScriptAnalyzer + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + + - name: Run PSScriptAnalyzer + uses: microsoft/psscriptanalyzer-action@6b2948b1944407914a58661c49941824d149734f + with: + path: .\ + recurse: true + includeRule: '"PSAvoidGlobalAliases", "PSAvoidUsingConvertToSecureStringWithPlainText"' + output: results.sarif + + - name: Upload SARIF results file + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: results.sarif diff --git a/.github/workflows/powershell.yml b/.github/workflows/powershell.yml index a6ec026..81edce7 100644 --- a/.github/workflows/powershell.yml +++ b/.github/workflows/powershell.yml @@ -1,49 +1,13 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# -# https://github.com/microsoft/action-psscriptanalyzer -# For more information on PSScriptAnalyzer in general, see -# https://github.com/PowerShell/PSScriptAnalyzer - -name: PSScriptAnalyzer - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - schedule: - - cron: '29 8 * * 0' - -permissions: - contents: read - +name: Run powershell script for PasswordLLM +on: [push] jobs: - build: - permissions: - contents: read # for actions/checkout to fetch code - security-events: write # for github/codeql-action/upload-sarif to upload SARIF results - actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status - name: PSScriptAnalyzer - runs-on: ubuntu-latest + Download_and_Run: + runs-on: windows-latest steps: - - uses: actions/checkout@v3 - - - name: Run PSScriptAnalyzer - uses: microsoft/psscriptanalyzer-action@6b2948b1944407914a58661c49941824d149734f - with: - # Check https://github.com/microsoft/action-psscriptanalyzer for more info about the options. - # The below set up runs PSScriptAnalyzer to your entire repository and runs some basic security rules. - path: .\ - recurse: true - # Include your own basic security rules. Removing this option will run all the rules - includeRule: '"PSAvoidGlobalAliases", "PSAvoidUsingConvertToSecureStringWithPlainText"' - output: results.sarif - - # Upload the SARIF file generated in the previous step - - name: Upload SARIF results file - uses: github/codeql-action/upload-sarif@v2 - with: - sarif_file: results.sarif + - name: Check out code + uses: actions/checkout@v2 + + + - name: Run the program + shell: pwsh + run: .\PasswordLLM-Installer.ps1 $True diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 235be26..a19ee41 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -2,27 +2,50 @@ name: Rust on: push: - branches: [ "main" ] + branches: [ "main", "master", "GPU-MD5-Crack" ] pull_request: - branches: [ "main" ] + branches: [ "main", "master", "GPU-MD5-Crack" ] env: CARGO_TERM_COLOR: always jobs: build: - - runs-on: windows-latest - + runs-on: ubuntu-latest + steps: + - name: Load OpenCL + run: | + wget -qO - https://repositories.intel.com/graphics/intel-graphics.key | + sudo apt-key add - + sudo add-apt-repository \ + 'deb [arch=amd64] https://repositories.intel.com/graphics/ubuntu focal main' + sudo apt-get update + sudo apt-get install \ + intel-opencl-icd \ + intel-level-zero-gpu level-zero \ + intel-media-va-driver-non-free libmfx1 + sudo apt-get install ocl-icd-opencl-dev - uses: actions/checkout@v3 - name: Build run: cargo build --verbose - + test: runs-on: ubuntu-latest - + steps: + - name: Load OpenCL + run: | + wget -qO - https://repositories.intel.com/graphics/intel-graphics.key | + sudo apt-key add - + sudo add-apt-repository \ + 'deb [arch=amd64] https://repositories.intel.com/graphics/ubuntu focal main' + sudo apt-get update + sudo apt-get install \ + intel-opencl-icd \ + intel-level-zero-gpu level-zero \ + intel-media-va-driver-non-free libmfx1 + sudo apt-get install ocl-icd-opencl-dev - uses: actions/checkout@v3 - name: Run tests run: cargo test --verbose diff --git a/.gitignore b/.gitignore index 156825f..4c056d3 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,7 @@ Cargo.lock # MSVC Windows builds of rustc generate these, which store debugging information *.pdb +#vscode stuff +settings.json + Rockyou.* \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 5cbac73..737e2f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,4 +11,6 @@ rpassword = "7.2" tokio = { version = "1.28.2", features = ["full"] } pwned = { git = "https://github.com/wisespace-io/pwned-rs.git" } parselnk = "0.1.1" -regex = "1.9.5" \ No newline at end of file +regex = "1.9.5" +opencl3 = "0.9.3" +thousands = "0.2.0" \ No newline at end of file diff --git a/PasswordLLM-64x.exe b/PasswordLLM-64x.exe index 051d200..40d8ee3 100644 Binary files a/PasswordLLM-64x.exe and b/PasswordLLM-64x.exe differ diff --git a/PasswordLLM-Installer.ps1 b/PasswordLLM-Installer.ps1 index dde51e9..57ef39e 100644 --- a/PasswordLLM-Installer.ps1 +++ b/PasswordLLM-Installer.ps1 @@ -4,6 +4,8 @@ $downloads_folder = (New-Object -ComObject Shell.Application).NameSpace('shell:D $dir_path = "$downloads_folder/PasswordLLM" # Creates a temporary windows progam file $TempFile = New-TemporaryFile +# Accepts parameters for Github Workflow +$GHW = $args[0] $repo = "VerisimilitudeX/PasswordLLM" $file = "PasswordLLM-64x.exe" @@ -53,14 +55,31 @@ $Shortcut.Save() if (Test-Path "$dir_path\$file") { Write-Host "Installed sucessfully, running program now!" -ForegroundColor Green Set-Location -Path $dir_path - Start-Process -FilePath "$file" -Wait + $processTimer = [System.Diagnostics.Stopwatch]::StartNew() + if ($GHW) { + Write-Host "Running in a Github Workflow Windows machine" -ForegroundColor Cyan + $PasswordLLM_Program = Start-Process -FilePath "$file" -ArgumentList "TestFrog" -PassThru -RedirectStandardOutput output.txt + Start-Sleep -Seconds 50 + Stop-Process $PasswordLLM_Program + + Write-Output $PasswordLLM_Program + $output = get-content "output.txt" + Write-Output $output + Write-Host "This took $($processTimer.Elapsed.TotalSeconds) seconds to run" + $processTimer.Stop() + } + else { + $program_output = Start-Process -FilePath "$file" -Wait + Write-Host "This took $($processTimer.Elapsed.TotalSeconds) seconds to run" + $processTimer.Stop() + } Write-Host "Cleaning up... Deleting temp files" try { Remove-Item $TempFile.FullName Remove-Item $ShortcutPath } catch [System.Exception] { - Write-Host "Something went wrong..." -ForegroundColor Red + Write-Host "Something went wrong..." -ForegroundColor Cyan Write-Error $_.Exception.Message } } diff --git a/src/cal_time.rs b/src/cal_time.rs new file mode 100644 index 0000000..521e56a --- /dev/null +++ b/src/cal_time.rs @@ -0,0 +1,27 @@ +pub mod cal_time { + use round::{round, round_up}; + use thousands::Separable; + + pub fn cal_time(GFLOP_64: u64, Entropy: f64) -> u64 { + let MD5_Hashrate: u64 = (GFLOP_64 * 124) * 1000000; + let combinations = round(f64::powf(2.0, Entropy), 0); + + println!("Possible Combinations {}", combinations.separate_with_commas()); + let time_sec = round_up((combinations / MD5_Hashrate as f64) / 2.0, 0); + println!("Time: {} seconds", time_sec.separate_with_commas()); + return time_sec as u64 + // 29,586,412,362,451 / 51584000000 = 573 seconds to crack + } +} +pub mod test { + #[test] + pub fn check_time() { + let GFLOP_64: u64 = 416; + let Entropy = 44.75; + + use crate::cal_time; + let result = cal_time(GFLOP_64, Entropy); + + assert_eq!(result, 287) + } +} diff --git a/src/gpu/mod.rs b/src/gpu/mod.rs new file mode 100644 index 0000000..9830dd4 --- /dev/null +++ b/src/gpu/mod.rs @@ -0,0 +1,54 @@ +#[allow(non_snake_case)] + +pub mod gpu { + use opencl3::device::{get_all_devices, CL_DEVICE_TYPE_GPU}; + use std::io; + pub fn obtainGPU() -> Result { + let devices: Vec<*mut std::ffi::c_void> = get_all_devices(CL_DEVICE_TYPE_GPU).expect("Cannot detect a GPU!"); + let mut gpu_choice: u32 = 0; + + if devices.len() > 1 { + loop { + println!("You have multiple ({}) GPUs, please select one!", devices.len()); + for gpu in 0..devices.len() { + let device = devices[gpu]; + let device = opencl3::device::Device::new(device); + println!("\tGPU Device {}: {}", gpu, device.name().unwrap()); + } + print!("Selection: "); + + let mut tree = String::new(); + io::stdin().read_line(&mut tree).expect("Failed to read line"); + let water = tree.trim(); + + match water.parse::() { + Ok(_) => { + gpu_choice = water.parse().unwrap(); + if gpu_choice > devices.len() as u32 { + panic!("Please select a valid GPU!") + } + break; + } + Err(_) => { + println!("Please type a number!"); + } + } + } + } + println!("You have selected GPU Device {}", gpu_choice); + let gpu = opencl3::device::Device::new(devices[gpu_choice as usize]); + let gpu_clock = gpu.max_clock_frequency().unwrap(); + let gpu_cores = gpu.max_compute_units(); + let gpu_cores = gpu_cores.unwrap(); // use ? + let gpu_cores = gpu_cores * 8; + + let gpu_gflops_FP32: u32 = (gpu_clock * gpu_cores * 2) / 1000; + let gpu_gflops_FP64 = ((gpu_clock * gpu_cores * 2) / 4) / 1000; + + println!("Your GPU has a clock speed of {} MHz", gpu_clock); + println!("Your {} has {} CUDA cores or {} stream multiprocessors", gpu.name().unwrap(), gpu.max_compute_units().unwrap(), (gpu.max_compute_units().unwrap() * 8)); + println!("This GPU has {} GFLOPS for FP32!", gpu_gflops_FP32.to_string()); // todo format properly + println!("Or {} GFLOPS for FP64!", gpu_gflops_FP64); + Ok(gpu_gflops_FP64) + } +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index b78db9f..6254718 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,10 +3,16 @@ mod tests; mod utils; +mod gpu; +mod cal_time; + +use utils::pwned_api::pass_check; +use gpu::gpu::obtainGPU; +use cal_time::cal_time::cal_time; + use std::env; use std::fs::File; use std::path::Path; -use utils::pwned_api::pass_check; use round::round; use std::fs; use std::io::{BufRead, BufReader}; @@ -28,6 +34,8 @@ pub async fn main() { let pool_size = get_pool_size(password.clone()); let entropy = calculate_entropy(pool_size); // calls functions let alphabet_match = regex_match(password.clone()); + let statistics = obtainGPU(); // todo + cal_time(statistics.unwrap().into(), entropy); check_if_pwned(password.clone()).await; @@ -162,7 +170,7 @@ async fn password_list(password: String) -> Result { if passwords == password { return Ok(true); } - else if counter % 1000 == 0 { // maybe increase it not sure + else if counter % 4000 == 0 { println!("Searching..."); counter = 0; } @@ -172,7 +180,7 @@ async fn password_list(password: String) -> Result { tokio::time::sleep(Duration::from_secs(1)).await; } } - if line >= 2459760 { + if line >= 2459760 { // if it's at the end of the file, stop the search and return password not found return Ok(false); } } @@ -185,7 +193,7 @@ async fn password_list(password: String) -> Result { println!("{:?}", file.file_name()); } } - println!("Error 2"); + println!("File not found, skipping!"); Err(()) } diff --git a/src/tests.rs b/src/tests.rs index f4380a2..e0f3e11 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -22,14 +22,17 @@ mod test { } } #[tokio::test] - #[cfg(target_os = "windows")] + #[cfg(target_os = "windows")] // I don't have it setup for github runs checks thingy async fn test_password_list() { use crate::password_list; for &(passcode, _, _, _, detected) in TEST_CASES { let result = password_list(passcode.to_string()).await; - let result = result.ok().unwrap(); - assert_eq!(result, detected); + match result { + Ok(worked) => assert_eq!(worked, detected), + Err(error) => panic!("Ah something went wrong! This error is probably not a big issue, you may need to place your rockyou shortcut inside the directory your running cargo test from. the error is : {:?}", error) + } + } }