2025-07-01 21:17:23 -03:00
# include "RyujinApp.hh"
bool RyujinApp : : OnInit ( ) {
2025-07-03 09:37:46 -03:00
2025-07-01 21:17:23 -03:00
auto * frame = new wxFrame (
2025-07-03 09:37:46 -03:00
2025-07-01 21:17:23 -03:00
nullptr ,
wxID_ANY ,
" Ryujin Obfuscator " ,
wxDefaultPosition ,
wxSize (
2025-07-03 09:37:46 -03:00
650 ,
2025-07-01 21:17:23 -03:00
580
) ,
wxDEFAULT_FRAME_STYLE & ~ ( wxRESIZE_BORDER | wxMAXIMIZE_BOX )
) ;
2025-07-03 09:37:46 -03:00
frame - > SetBackgroundColour (
2025-07-01 21:17:23 -03:00
wxColour (
25 ,
25 ,
25
) ) ;
frame - > SetFont (
wxFont (
10 ,
wxFONTFAMILY_SWISS ,
wxFONTSTYLE_NORMAL ,
wxFONTWEIGHT_NORMAL
2025-07-03 09:37:46 -03:00
2025-07-01 21:17:23 -03:00
) ) ;
2025-07-03 09:37:46 -03:00
auto * panel = new wxPanel (
2025-07-01 21:17:23 -03:00
frame ,
2025-07-03 09:37:46 -03:00
wxID_ANY
2025-07-01 21:17:23 -03:00
) ;
2025-07-03 09:37:46 -03:00
panel - > SetBackgroundColour (
2025-07-01 21:17:23 -03:00
2025-07-03 09:37:46 -03:00
frame - > GetBackgroundColour ( )
2025-07-01 21:17:23 -03:00
) ;
2025-07-03 09:37:46 -03:00
auto * topSizer = new wxBoxSizer (
2025-07-01 21:17:23 -03:00
2025-07-03 09:37:46 -03:00
wxVERTICAL
2025-07-01 21:17:23 -03:00
) ;
2025-07-03 09:37:46 -03:00
if (
auto * icon = LoadPngFromRes (
panel ,
wxID_ANY ,
IDB_PNG1
) )
topSizer - > Add (
icon ,
0 ,
wxALIGN_CENTER | wxTOP ,
10
) ;
2025-07-01 21:17:23 -03:00
topSizer - > Add (
new wxStaticLine (
2025-07-03 09:37:46 -03:00
panel
2025-07-01 21:17:23 -03:00
) ,
0 ,
wxEXPAND | wxLEFT | wxRIGHT | wxTOP ,
15
) ;
auto * pathBox = new wxStaticBoxSizer (
wxVERTICAL ,
2025-07-03 09:37:46 -03:00
panel ,
2025-07-01 21:17:23 -03:00
" Paths "
) ;
2025-07-03 09:37:46 -03:00
pathBox - > GetStaticBox ( ) - > SetForegroundColour (
2025-07-01 21:17:23 -03:00
* wxWHITE
) ;
m_input = DrawnPathRow (
2025-07-03 09:37:46 -03:00
panel ,
2025-07-01 21:17:23 -03:00
pathBox ,
" Input EXE: " ,
wxID_HIGHEST + 1
) ;
m_pdb = DrawnPathRow (
2025-07-03 09:37:46 -03:00
panel ,
pathBox ,
" PDB File: " ,
2025-07-01 21:17:23 -03:00
wxID_HIGHEST + 2
) ;
m_output = DrawnPathRow (
2025-07-03 09:37:46 -03:00
panel ,
2025-07-01 21:17:23 -03:00
pathBox ,
" Output EXE: " ,
wxID_HIGHEST + 3
) ;
topSizer - > Add (
pathBox ,
0 ,
wxEXPAND | wxALL ,
15
) ;
auto * optionsBox = new wxStaticBoxSizer (
wxVERTICAL ,
2025-07-03 09:37:46 -03:00
panel ,
2025-07-01 21:17:23 -03:00
" Obfuscation Options "
) ;
2025-07-03 09:37:46 -03:00
optionsBox - > GetStaticBox ( ) - > SetForegroundColour (
2025-07-01 21:17:23 -03:00
* wxWHITE
) ;
auto * optionsSizer = new wxGridSizer (
2 ,
3 ,
10 ,
10
) ;
m_virtualize = DrawnStyledCheckbox (
2025-07-03 09:37:46 -03:00
panel ,
2025-07-01 21:17:23 -03:00
" Virtualize "
) ;
m_junk = DrawnStyledCheckbox (
2025-07-03 09:37:46 -03:00
panel ,
2025-07-01 21:17:23 -03:00
" Junk Code "
) ;
m_encrypt = DrawnStyledCheckbox (
2025-07-03 09:37:46 -03:00
panel ,
2025-07-01 21:17:23 -03:00
" Encrypt "
) ;
m_randomSection = DrawnStyledCheckbox (
2025-07-03 09:37:46 -03:00
panel ,
2025-07-01 21:17:23 -03:00
" Random Section "
) ;
m_obfuscateIat = DrawnStyledCheckbox (
2025-07-03 09:37:46 -03:00
panel ,
2025-07-01 21:17:23 -03:00
" Obfuscate IAT "
) ;
m_ignoreOriginalCodeRemove = DrawnStyledCheckbox (
2025-07-03 09:37:46 -03:00
panel ,
2025-07-01 21:17:23 -03:00
" Ignore Original Code Removal "
) ;
2025-07-10 20:55:39 -03:00
m_isAntiDebugWithTroll = DrawnStyledCheckbox (
panel ,
" Antidebug(User + Kernel) + Troll Reversers "
) ;
m_isAntiDebugNormal = DrawnStyledCheckbox (
panel ,
" Antidebug(User + Kernel) + Terminate "
) ;
2025-07-12 21:26:12 -03:00
m_isAntiDump = DrawnStyledCheckbox (
panel ,
" AntiDump "
) ;
2025-07-01 21:17:23 -03:00
optionsSizer - > Add (
m_virtualize
) ;
optionsSizer - > Add (
m_junk
) ;
optionsSizer - > Add (
m_encrypt
) ;
optionsSizer - > Add (
m_randomSection
) ;
optionsSizer - > Add (
m_obfuscateIat
) ;
optionsSizer - > Add (
m_ignoreOriginalCodeRemove
2025-07-10 20:55:39 -03:00
) ;
optionsSizer - > Add (
m_isAntiDebugWithTroll
) ;
optionsSizer - > Add (
m_isAntiDebugNormal
2025-07-12 21:26:12 -03:00
) ;
optionsSizer - > Add (
m_isAntiDump
2025-07-01 21:17:23 -03:00
) ;
optionsBox - > Add (
optionsSizer ,
0 ,
wxEXPAND | wxALL ,
10
) ;
topSizer - > Add (
optionsBox ,
0 ,
wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM ,
15
) ;
auto * procBox = new wxStaticBoxSizer (
wxVERTICAL ,
2025-07-03 09:37:46 -03:00
panel ,
2025-07-01 21:17:23 -03:00
" Procedures to Obfuscate "
) ;
2025-07-03 09:37:46 -03:00
procBox - > GetStaticBox ( ) - > SetForegroundColour (
2025-07-01 21:17:23 -03:00
* wxWHITE
) ;
m_procList = new wxListBox (
2025-07-03 09:37:46 -03:00
panel ,
2025-07-01 21:17:23 -03:00
wxID_ANY ,
wxDefaultPosition ,
wxDefaultSize ,
0 ,
nullptr ,
wxBORDER_NONE
) ;
2025-07-03 09:37:46 -03:00
m_procList - > SetMinSize (
wxSize (
- 1 ,
200
) ) ;
2025-07-01 21:17:23 -03:00
m_procList - > SetBackgroundColour (
wxColour (
40 ,
40 ,
40
) ) ;
m_procList - > SetForegroundColour (
* wxWHITE
) ;
procBox - > Add (
m_procList ,
1 ,
wxEXPAND | wxBOTTOM ,
5
) ;
auto * procBtnRow = new wxBoxSizer (
wxHORIZONTAL
) ;
procBtnRow - > Add (
DrawnRyujinButton (
2025-07-03 09:37:46 -03:00
panel ,
2025-07-01 21:17:23 -03:00
" Add " ,
wxID_HIGHEST + 4
2025-07-03 09:37:46 -03:00
2025-07-01 21:17:23 -03:00
) ,
0 ,
wxRIGHT ,
10
) ;
procBtnRow - > Add (
DrawnRyujinButton (
2025-07-03 09:37:46 -03:00
panel ,
2025-07-01 21:17:23 -03:00
" Remove " ,
wxID_HIGHEST + 5
2025-07-03 09:37:46 -03:00
2025-07-01 21:17:23 -03:00
) ) ;
procBox - > Add (
procBtnRow ,
0 ,
wxALIGN_RIGHT
) ;
topSizer - > Add (
procBox ,
1 ,
wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM ,
15
) ;
m_progress = new wxGauge (
2025-07-03 09:37:46 -03:00
panel ,
2025-07-01 21:17:23 -03:00
wxID_ANY ,
100
) ;
m_progress - > SetMinSize (
wxSize (
2025-07-03 09:37:46 -03:00
2025-07-01 21:17:23 -03:00
- 1 ,
14
) ) ;
m_progress - > SetForegroundColour (
wxColour (
0 ,
150 ,
255
) ) ;
m_progress - > SetBackgroundColour (
wxColour (
45 ,
45 ,
45
) ) ;
auto * runBtn = DrawnRyujinButton (
2025-07-03 09:37:46 -03:00
panel ,
2025-07-01 21:17:23 -03:00
" Run Obfuscator " ,
wxID_HIGHEST + 6
) ;
runBtn - > SetMinSize (
wxSize (
160 ,
42
) ) ;
runBtn - > SetFont (
wxFont (
11 ,
wxFONTFAMILY_SWISS ,
wxFONTSTYLE_NORMAL ,
wxFONTWEIGHT_BOLD
) ) ;
auto * runRow = new wxBoxSizer (
wxHORIZONTAL
) ;
runRow - > Add (
runBtn ,
0 ,
wxRIGHT ,
20
) ;
runRow - > Add (
m_progress ,
1 ,
wxALIGN_CENTER_VERTICAL
) ;
topSizer - > Add (
runRow ,
0 ,
wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND ,
20
) ;
2025-07-03 09:37:46 -03:00
panel - > SetSizer (
2025-07-01 21:17:23 -03:00
topSizer
) ;
2025-07-03 09:37:46 -03:00
topSizer - > SetSizeHints (
panel
) ;
frame - > Fit ( ) ;
frame - > Centre ( ) ;
frame - > Show ( ) ;
2025-07-01 21:17:23 -03:00
2025-07-03 09:37:46 -03:00
frame - > CreateStatusBar ( ) ;
2025-07-01 21:17:23 -03:00
BindFileDialogs (
frame
) ;
BindListEvents (
frame
) ;
BindRunEvent (
frame
) ;
return true ;
}
2025-07-03 09:37:46 -03:00
2025-07-01 21:17:23 -03:00
auto RyujinApp : : DrawnPathRow ( wxWindow * parent , wxBoxSizer * sizer , const wxString & label , int buttonId ) - > wxTextCtrl * {
auto * row = new wxBoxSizer (
wxHORIZONTAL
) ;
auto * lbl = new wxStaticText (
parent ,
wxID_ANY ,
label
) ;
lbl - > SetForegroundColour (
* wxWHITE
) ;
auto * txt = new wxTextCtrl (
parent ,
wxID_ANY ,
" " ,
wxDefaultPosition ,
wxSize (
- 1 ,
28
) ,
wxBORDER_NONE
) ;
txt - > SetBackgroundColour (
wxColour (
40 ,
40 ,
40
) ) ;
txt - > SetForegroundColour (
* wxWHITE
) ;
auto * btn = DrawnRyujinButton (
parent ,
" Browse " ,
buttonId
) ;
row - > Add (
lbl ,
0 ,
wxALIGN_CENTER_VERTICAL | wxRIGHT ,
10
) ;
row - > Add (
txt ,
1 ,
wxRIGHT ,
10
) ;
row - > Add (
btn
) ;
sizer - > Add (
row ,
0 ,
wxEXPAND | wxALL ,
8
) ;
return txt ;
}
auto RyujinApp : : DrawnStyledCheckbox ( wxWindow * parent , const wxString & label ) - > wxCheckBox * {
auto * box = new wxCheckBox (
parent ,
wxID_ANY ,
label
) ;
box - > SetForegroundColour (
* wxWHITE
) ;
return box ;
}
auto RyujinApp : : DrawnRyujinButton ( wxWindow * parent , const wxString & label , int id ) - > wxButton * {
auto * btn = new wxButton (
parent ,
id ,
label ,
wxDefaultPosition ,
wxDefaultSize ,
wxBORDER_NONE
) ;
btn - > SetBackgroundColour (
wxColour (
60 ,
60 ,
60
) ) ;
btn - > SetForegroundColour (
* wxWHITE
) ;
return btn ;
}
auto RyujinApp : : BindFileDialogs ( wxFrame * frame ) - > void {
auto bind = [ = ] ( int id , wxTextCtrl * target , const wxString & ext , bool save = false ) {
frame - > Bind ( wxEVT_BUTTON , [ = ] ( wxCommandEvent & ) {
wxFileDialog dlg ( frame , save ? " Save file " : " Select file " , " " , " " , " *. " + ext + " |*. " + ext ,
save ? wxFD_SAVE | wxFD_OVERWRITE_PROMPT : wxFD_OPEN ) ;
if ( dlg . ShowModal ( ) = = wxID_OK )
target - > SetValue ( dlg . GetPath ( ) ) ;
} , id ) ;
} ;
bind ( wxID_HIGHEST + 1 , m_input , " exe " ) ;
bind ( wxID_HIGHEST + 2 , m_pdb , " pdb " ) ;
bind ( wxID_HIGHEST + 3 , m_output , " exe " , true ) ;
}
auto RyujinApp : : BindListEvents ( wxFrame * frame ) - > void {
frame - > Bind ( wxEVT_BUTTON , [ = ] ( wxCommandEvent & ) {
2025-07-03 09:37:46 -03:00
wxTextEntryDialog dlg ( frame , " Enter comma-separated procedures or a unique procedure name: " , " Procedures to obfuscate " ) ;
2025-07-01 21:17:23 -03:00
if ( dlg . ShowModal ( ) = = wxID_OK ) {
wxArrayString list = wxSplit ( dlg . GetValue ( ) , ' , ' ) ;
for ( auto & p : list )
m_procList - > Append ( p . Trim ( ) ) ;
}
} , wxID_HIGHEST + 4 ) ;
frame - > Bind ( wxEVT_BUTTON , [ = ] ( wxCommandEvent & ) {
int sel = m_procList - > GetSelection ( ) ;
if ( sel ! = wxNOT_FOUND )
m_procList - > Delete ( sel ) ;
} , wxID_HIGHEST + 5 ) ;
}
auto RyujinApp : : BindRunEvent ( wxFrame * frame ) - > void {
frame - > Bind ( wxEVT_BUTTON , [ = ] ( wxCommandEvent & ) {
2025-07-03 09:37:46 -03:00
2025-07-03 20:07:47 -03:00
if ( m_input - > IsEmpty ( ) | | m_pdb - > IsEmpty ( ) | | m_output - > IsEmpty ( ) ) {
wxMessageBox (
" To obfuscate you mandatory need to provide the following informations: Input PE, Input PE PDB, Ouput PE. \n Please check if these files are valid, they cannot be empty! " ,
" Error, please more attention " ,
wxOK | wxICON_ERROR
) ;
return ;
}
2025-07-01 21:17:23 -03:00
frame - > SetStatusText ( " Starting obfuscation... " ) ;
m_progress - > Pulse ( ) ;
2025-07-03 09:37:46 -03:00
std : : thread ( [ = ] ( ) {
RyujinObfuscatorConfig core ;
// Options Configuration
core . m_isEncryptObfuscatedCode = m_encrypt - > IsChecked ( ) ;
core . m_isIatObfuscation = m_obfuscateIat - > IsChecked ( ) ;
core . m_isIgnoreOriginalCodeRemove = m_ignoreOriginalCodeRemove - > IsChecked ( ) ;
core . m_isJunkCode = m_junk - > IsChecked ( ) ;
core . m_isRandomSection = m_randomSection - > IsChecked ( ) ;
core . m_isVirtualized = m_virtualize - > IsChecked ( ) ;
2025-07-12 21:26:12 -03:00
core . m_isAntiDump = m_isAntiDump - > IsChecked ( ) ;
2025-07-03 09:37:46 -03:00
2025-07-10 20:55:39 -03:00
if ( m_isAntiDebugWithTroll - > IsChecked ( ) ) {
core . m_isAntiDebug = TRUE ;
core . m_isTrollRerversers = TRUE ;
}
if ( m_isAntiDebugNormal - > IsChecked ( ) ) {
core . m_isAntiDebug = TRUE ;
core . m_isTrollRerversers = FALSE ;
}
2025-07-03 09:37:46 -03:00
auto count = m_procList - > GetCount ( ) ;
2025-07-10 20:55:39 -03:00
int index = 0 ;
for ( auto i = 0 ; i < count & & index < MAX_PROCEDURES ; + + i ) {
2025-07-03 09:37:46 -03:00
2025-07-10 20:55:39 -03:00
auto item = m_procList - > GetString ( i ) . ToStdString ( ) ;
if ( ! item . empty ( ) ) {
strncpy_s (
core . m_strProceduresToObfuscate . procedures [ index ] ,
item . c_str ( ) ,
MAX_PROCEDURE_NAME_LEN - 1
) ;
+ + index ;
}
2025-07-03 09:37:46 -03:00
}
2025-07-10 20:55:39 -03:00
core . m_strProceduresToObfuscate . procedureCount = index ;
std : : string input = m_input - > GetValue ( ) . ToStdString ( ) ;
std : : string pdb = m_pdb - > GetValue ( ) . ToStdString ( ) ;
std : : string output = m_output - > GetValue ( ) . ToStdString ( ) ;
auto bSuccess = core . RunRyujin ( input , pdb , output , core ) ;
2025-07-03 09:37:46 -03:00
frame - > CallAfter ( [ = ] ( ) {
if ( bSuccess ) {
m_progress - > SetValue ( 100 ) ;
frame - > SetStatusText ( " Obfuscation complete. " ) ;
} else {
m_progress - > SetValue ( 50 ) ;
frame - > SetStatusText ( " Obfuscation error. " ) ;
}
} ) ;
} ) . detach ( ) ;
2025-07-01 21:17:23 -03:00
} , wxID_HIGHEST + 6 ) ;
2025-07-03 09:37:46 -03:00
}
auto RyujinApp : : LoadPngFromRes ( wxWindow * parent , wxWindowID id , int resId ) - > wxStaticBitmap * {
wxImage : : AddHandler (
new wxPNGHandler
) ;
auto hInst = reinterpret_cast < HINSTANCE > ( GetModuleHandle (
_In_ NULL
) ) ;
auto rs = FindResource (
_In_ hInst ,
_In_ MAKEINTRESOURCE ( resId ) ,
_In_ wxT ( " PNG " )
) ;
if ( ! rs ) return nullptr ;
auto hGlob = LoadResource (
_In_opt_ hInst ,
_In_ rs
) ;
auto * data = LockResource (
_In_ hGlob
) ;
auto size = SizeofResource (
_In_opt_ hInst ,
_In_ rs
) ;
wxMemoryInputStream mis (
data ,
size
) ;
wxImage img (
mis ,
wxBITMAP_TYPE_PNG
) ;
if ( ! img . IsOk ( ) ) return nullptr ;
return new wxStaticBitmap (
parent ,
id ,
wxBitmap (
img
) ) ;
}