Tag: file

Microsoft Windows

Invoking UAC for Privilege Escalation in batch file

@echo off at >nul if %errorlevel% == 0 goto run_elevated   echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%getUACpriv.vbs" echo UAC.ShellExecute %0, "", "", "runas", 1 >> "%temp%getUACpriv.vbs"   ECHO Privilege Escalation   "%temp%getUACpriv.vbs" >nul exit /B   :run_elevated del "%temp%getUACpriv.vbs" 2>nul CD "%~dp0"   REM your commands   pause>nul@echo off at >nul if %errorlevel% == …

C#

Download file from url with C#

In the following code we are going to use WebClient class to download a file from a web location. public void DownloadFile(String URL){ Uri uri = new Uri(URL); WebClient wb = new WebClient(); wb.DownloadFileCompleted += new AsyncCompletedEventHandler(completed); wb.DownloadFileAsync(uri, System.IO.Path.GetTempPath() + Path.GetFileName(uri.LocalPath)); }   private void completed(object sender, AsyncCompletedEventArgs e) { try { Console.WriteLine("Download completed"); } …

Auditing, Detection, Enumeration, Exploitation, Scanners

Local and Remote file inclusion

fimap – A little open source tool for local and remote file inclusion auditing and exploitation. It is published under GNU GPLv2.   fimap is awritten in python and can find, prepare, audit, exploit and even google automaticly for local and remote file inclusion bugs in webapps. fimap should be something like sqlmap just for …

Microsoft Windows

Hide|Show extensions for known file types from cmd

Open command line window and execute: Hide extensions reg add HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerAdvanced /v HideFileExt /t REG_DWORD /d 1 /freg add HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerAdvanced /v HideFileExt /t REG_DWORD /d 1 /f Show Extensions reg add HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerAdvanced /v HideFileExt /t REG_DWORD /d 0 /freg add HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerAdvanced /v HideFileExt /t REG_DWORD /d 0 /f

C#

Upload files with ftp and C#

C# and .Net framework offer FtpWebRequest for ftp transactions. FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create("ftp://example.org/test.txt");   ftp.Credentials = new NetworkCredential("username", "password"); ftp.Method = WebRequestMethods.Ftp.UploadFile; ftp.KeepAlive = false; ftp.UsePassive = true; ftp.UseBinary = true; ftp.KeepAlive = false; ftp.Timeout = timeout;   StreamReader sr= new StreamReader("test.txt"); byte [] content= Encoding.UTF8.GetBytes(sr.ReadToEnd()); sr.Close();   ftp.ContentLength = content.Length;   Stream stream= ftp.GetRequestStream(); …

Microsoft Windows

Connect to a file share

We are going to use the net use command. usage: net use drive_letter: \ip_addressshared_folder_namenet use drive_letter: \ip_addressshared_folder_name or net use drive_letter: \computer_nameshared_folder_namenet use drive_letter: \computer_nameshared_folder_name example: net use K: \192.168.1.10mysharesnet use K: \192.168.1.10myshares or net use K: \george-pcmysharesnet use K: \george-pcmyshares