Viotto

Members
  • Content count

    5
  • Joined

  • Last visited

Community Reputation

3 Neutral

About Viotto

  • Rank
    Junior Member
  • Birthday 04/24/1990
  1. Thanks cracksman, same for me
  2. With this simple class you can create a FileDialog without any form needed, also without the need of using comdlg32.OCX and its visual CommonDialog component on a form.It is also more performant then when using the OCX component.The screenshot below shows performance difference when opening a FileDialog, left with OCX, right direct DLL calls. You can find this and more coding work of mine on my website, breaking-security.net' cFileDialog.cls' by Viotto - www.BreakingSecurity.net'' Provides CommonDialog functionality,' without the need of ocx file and graphical component.'' ComDlg32.OCX provides an easy-to-use interface, but if you use the OCX control,' you have to load the module into memory and also distribute a 90K OCX file to users of your software.' To improve performance, and eliminate the need of additional dependencies,' you should minimize the use of controls in your applications.' Instead, you can use the Win32 API calls directly.'' More info from Microsoft: https://support.micr...en-us/kb/161286 Option Explicit Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _ "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias _ "GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Long Private Declare Sub CopyMemory Lib "kernel32" Alias _ "RtlMoveMemory" (lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long) Private Type OPENFILENAME lStructSize As Long hwndOwner As Long hInstance As Long lpstrFilter As String lpstrCustomFilter As String nMaxCustFilter As Long nFilterIndex As Long lpstrFile As String nMaxFile As Long lpstrFileTitle As String nMaxFileTitle As Long lpstrInitialDir As String lpstrTitle As String flags As Long nFileOffset As Integer nFileExtension As Integer lpstrDefExt As String lCustData As Long lpfnHook As Long lpTemplateName As StringEnd Type Private Dlg As OPENFILENAMEPrivate bDialogExecuted As Boolean ' will be true if user pressed OK, false if dialog was canceled ' This can be used to set an initial filename before displaying the dialogPublic Property Let strFile(value As String) CopyMemory ByVal Dlg.lpstrFile, ByVal value, Len(value)End Property ' This can be used to retrieve full path of the selected file, after dialog display.Public Property Get strFile() As String strFile = Dlg.lpstrFileEnd Property ' This can be used to get the filename (without path) of the selected file, after dialog display.Public Property Get FileName() As String FileName = Dlg.lpstrFileTitleEnd Property Public Property Get Executed() As Boolean Executed = bDialogExecutedEnd Property ' Set dialog titlePublic Property Let Title(value As String) Dlg.lpstrTitle = valueEnd Property ' Set default file extensionPublic Property Let DefaultExt(value As String) Dlg.lpstrDefExt = valueEnd Property Public Property Let Filter(value As String) Dlg.lpstrFilter = valueEnd Property Public Property Let Owner(value As Long) Dlg.hwndOwner = valueEnd Property Public Sub Initialize() Dlg.lStructSize = Len(Dlg) Dlg.hInstance = App.hInstance Dlg.nFilterIndex = 1 Dlg.lpstrFile = String(257, 0) Dlg.nMaxFile = Len(Dlg.lpstrFile) - 1 Dlg.lpstrFileTitle = Dlg.lpstrFile Dlg.nMaxFileTitle = Dlg.nMaxFile Dlg.lpstrInitialDir = vbNullString Dlg.flags = 0End Sub Public Sub ShowOpenDialog() bDialogExecuted = GetOpenFileName(Dlg)End Sub Public Sub ShowSaveDialog() bDialogExecuted = GetSaveFileName(Dlg)End Sub
  3. This sample I coded is intended to show a method to make different processes communicate and exchange data among them.You can download full Delphi project attached.A thanks goes to Peter Bloomfield, who wrote a nice tutorial about Windows pipes in C++.You can find this and more sources of mine, as well as free and private software I made on my website, www.breaking-security.net program PipeServer;// Server application which creates an inbound pipe and waits for data from client processes.{$APPTYPE CONSOLE}uses SysUtils, Windows;procedure ReceivePipeData();var pipe: Cardinal; RecBuffer: Array[0..999] of Byte; numBytesRead: DWORD; result: LongBool; sReadData: AnsiString; sa: SECURITY_ATTRIBUTES; sd: SECURITY_DESCRIPTOR;begin // Must grant access rights in case User Account Control is on, on WinVista and above, // and communicating processes are under a different user (which can be also SYSTEM). // Otherwise, the other side of the pipe will receive ERROR_ACCESS_DENIED upon CreateFile(). // If UAC is on and we are trying to use pipe between a userlevel and a system process, // even if we are inside the same user account, pipe communication will fail. // In order to avoid this, we must initialize a security descriptor for the pipe. InitializeSecurityDescriptor(@sd, SECURITY_DESCRIPTOR_REVISION); // There is an important difference between an empty and a nonexistent DACL. // When a DACL is empty, it contains no access control entries (ACEs); therefore, no access rights are explicitly granted. // As a result, access to the object is implicitly denied. // When an object has no DACL (when the pDacl parameter is NULL), // no protection is assigned to the object, and all access requests are granted. SetSecurityDescriptorDacl(@sd, True, nil, False); sa.bInheritHandle := false; sa.lpSecurityDescriptor := @sd; sa.nLength := sizeof(sa); while true do begin repeat // Create a new pipe to receive data pipe := CreateNamedPipe( '\\.\pipe\SamplePipe', // Our pipe name PIPE_ACCESS_INBOUND, // Read-only pipe PIPE_TYPE_MESSAGE or PIPE_READMODE_MESSAGE, //Using Message mode PIPE_UNLIMITED_INSTANCES , 0, // No outbound buffer 0, // No inbound buffer 0, // Use default wait time @sa // Set security attributes to grant access rights ); if (pipe = INVALID_HANDLE_VALUE) then begin Write('[ERROR] Failed to create pipe. Error code ' + IntToStr(GetLastError()) + #13#10 + 'Press Enter to retry'); Readln; end; until pipe <> INVALID_HANDLE_VALUE; WriteLn('[iNFO] Inbound pipe created! Waiting for a client process to connect...'); // This call blocks until a client process connects to the pipe result := ConnectNamedPipe(pipe, nil); if (result = false) then begin Writeln('[ERROR] Failed to connect to pipe. Error code ' + IntToStr(GetLastError())); end else begin Writeln('[iNFO] Client connected! Waiting for data...'); numBytesRead := 0; // The read operation will block until there is data to read result := ReadFile( pipe, RecBuffer[0], // The data from the pipe will be put here sizeof(RecBuffer), // Number of bytes allocated numBytesRead, // This will store number of bytes actually read nil // Not using overlapped IO ); if (result = false) then begin Writeln('[ERROR] Failed to read pipe data! Error code ' + IntToStr(GetLastError())); end else begin SetString(sReadData,PAnsiChar(@recBuffer[0]), numBytesRead); //Copy byte array to string Writeln('[sUCCESS] Data received: ' + sReadData); end; end; //Close our pipe handle CloseHandle(pipe); end;end;//Program start procedurebegin Writeln('*** Pipe Server Application ***' + #13#10); Write('[iNFO] Press Enter to create pipe server and start listening for incoming data'); ReadLn; ReceivePipeData();end.program PipeClient;// Client application which sends data to pipe server.{$APPTYPE CONSOLE}usesSysUtils,Windows,Classes;// Data to send via pipe is read from a file.function GetDataFromFile(sFileName: AnsiString): AnsiString;varDataFile: TFileStream;ReadBuffer: array of Byte;sDataToSend: AnsiString;begin try DataFile := TFileStream.Create( sFileName , fmOpenRead); SetLength(ReadBuffer, DataFile.Size); DataFile.Read(ReadBuffer[0], Length(ReadBuffer)); SetString(sDataToSend,PAnsiChar(@ReadBuffer[0]), DataFile.Size); //Copy byte array to string DataFile.Free; Result := sDataToSend; except Result := ''; end;end;procedure SendPipeData();varpipe: Cardinal;numBytesWritten: DWORD;result: LongBool;sDataToSend: AnsiString;begin repeat // Open the named pipe, previusly created by server application pipe := CreateFile( '\\.\pipe\SamplePipe', // Our pipe name GENERIC_WRITE, FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 ); if (pipe = INVALID_HANDLE_VALUE) then begin Write('[ERROR] Failed to open pipe (server must be running first).' + #13#10 + 'Press Enter to retry'); Readln; end; until pipe <> INVALID_HANDLE_VALUE; repeat //Get data to send from file sDataToSend := GetDataFromFile(ExtractFilePath(ParamStr(0)) + 'DataToSend.txt'); if sDataToSend = '' then begin Write('[ERROR] Unable to read data from file (may be unexistent or empty).' + #13#10 + 'Press Enter to retry'); Readln; end; until sDataToSend <> ''; numBytesWritten := 0; result := WriteFile( pipe, // Handle to our outbound pipe sDataToSend[1], // Pointer to data to send Length(sDataToSend), // Length of data to send (bytes) numBytesWritten, // Will store actual amount of data sent nil // Not using overlapped IO ); if (result = false) then Writeln('[ERROR] Failed to send pipe data. Error code ' + IntToStr(GetLastError())) else Writeln('[sUCCESS] Pipe data sent: ' + sDataToSend); // Close the pipe handle CloseHandle(pipe);end;//Program start procedurebegin Writeln('*** Pipe Client Application ***' + #13#10); while true do begin Write('[iNFO] Press Enter to send pipe data to server'); Readln; SendPipeData(); end;end. PipeSample (Delphi).zip
  4. A simple and fast recursive function which can be used to search for a filename or part of it, inside a specified folder and all of its subdirectories. #include #include #include using namespace std; bool FileSearch(string sSearch, string sFolder) { // This recursive function will search for a filename or part of it, // inside the specified folder and in all its subfolders. // Coded by Viotto - http://Breaking-Security.net std::transform(sSearch.begin(), sSearch.end(), sSearch.begin(), ::tolower); // Check for final slash in path and append it if missing if (sFolder[sFolder.length() -1] != '\\') { sFolder += "\\"; } WIN32_FIND_DATA FileInfo; HANDLE hFind = FindFirstFileA(string(sFolder + "*").c_str(), &FileInfo); if (hFind == INVALID_HANDLE_VALUE) { FindClose(hFind); return false; } string sFileInfo; while (FindNextFile(hFind, &FileInfo) != 0) { if (FileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY && strcmp(FileInfo.cFileName, ".") != 0 && strcmp(FileInfo.cFileName, "..") != 0) { string sRecursiveDir = sFolder + string(FileInfo.cFileName); FileSearch(sSearch, sRecursiveDir); } string sFileName(FileInfo.cFileName); std::transform(sFileName.begin(), sFileName.end(), sFileName.begin(), ::tolower); if (sFileName.find(sSearch) != string::npos) { //Search string has been found inside file name printf(string(sFolder + FileInfo.cFileName + "\n").c_str()); } } FindClose(hFind); return true; } // Usage example: // filesearch "Notepad" "C:\Windows" void main(int argc, char* argv[]) { if (argc == 3) { FileSearch(argv[1], argv[2]); printf("Search finished!\n"); } else printf("Wrong number of parameters\n"); system("pause"); }
  5. Hello guys, Viotto here, saw some familiar names around here, greetings to everybody! Created this account 2 years ago actually but never posted yet on ic0de but well, better later then never. By the way, I am a C/C++, Delphi and VB6 developer, particularly passionate about the insecurity field. I own a website where I host some of my snippets, sources, free programs and programs I sell. Name's breaking-security.net Well that's all for now, plan to release some of my stuff on here as well, so see you on board