giovedì 29 settembre 2011

Win32 C++: sapere se un'istanza del programma è già caricata

Breve esempio di una possibile soluzione al problema della ricerca di un'istanza del programma già attiva.
Il codice si basa sulla creazione di un semaforo ed il relativo check della sua esistenza al caricamento dell'applicazione. L'API Win32 in gioco è la CreateSemaphore.

Routine da chiamare nel main o nell' InitHistance della vostra applicazione:

bool AmIAlreadyActive()
{
TCHAR* szSemName = _T("MySemaphoreApp"); // utilizzare il nome che più aggrada
MyHandle=  CreateSemaphore(NULL, 0, 1, szSemName);

return (!MyHandle || (GetLastError() == ERROR_ALREADY_EXISTS)) ? true : false; 
}
MyHandle è una variabile di tipo HANDLE.
Ricordarsi di chiude l'handle al termine del programma mediante
CloseHandle(MyHandle);

mercoledì 28 settembre 2011

Keygenning Mirc 6.21

Dato l'ormai obsolescenza di questa versione di Mirc e dato che la protezione implementata nelle nuove versioni è diversa, credo di poter pubblicare senza arrecare danno alcuno questo breve e schematico tut sul keygenning.












A questo indirizzo è possibile scaricare il progetto in Visual Basic 6 del keygen

ATTENZIONE: il reverse engineering è una pratica ai limiti della legalità, pertanto con questo mio post non voglio incoraggiare nessuno a commettere reati, ma soltanto solleticare la curiosità riguardo le possibili sfumature dell'informatica.
Per questo motivo non farò accenni ai tool usati.

martedì 27 settembre 2011

Visual basic 6: lanciare un processo esterno con CreateProcess


Breve snippet di codice per aprire un processo esterno ed aspettare che finisca il lavoro in Visual Basic 6 utilizzando l'API CreateProcess e WaitForSingleObject

Private Type STARTUPINFO
        cb As Long
        lpReserved As String
        lpDesktop As String
        lpTitle As String
        dwX As Long
        dwY As Long
        dwXSize As Long
        dwYSize As Long
        dwXCountChars As Long
        dwYCountChars As Long
        dwFillAttribute As Long
        dwFlags As Long
        wShowWindow As Integer
        cbReserved2 As Integer
        lpReserved2 As Long
        hStdInput As Long
        hStdOutput As Long
        hStdError As Long
End Type

Private Type PROCESS_INFORMATION
        hProcess As Long
        hThread As Long
        dwProcessId As Long
        dwThreadId As Long
End Type

Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, byVal lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Private Declare Function GetLastError Lib "kernel32" () As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As LongPrivate Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Private Const NORMAL_PRIORITY_CLASS = &H20
dwMilliseconds As Long) As Long
Private Const INFINITE = &HFFFF      '  Timeout infinito
Private Const STARTF_USESHOWWINDOW = &H1

Private Const SW_SHOW = 5

Private Sub LaunchAndWait(ByVal ppath As String, ByVal cmdLine, ByVal swWnd As Long)
On Error GoTo errLW
Dim p As Long
Dim workDir As String
Dim SI As STARTUPINFO
Dim PI As PROCESS_INFORMATION

workDir = Left$(ppath, Len(ppath) - (Len(ppath) - InStrRev(ppath, "\")))

SI.cb = Len(SI)
SI.dwFlags = STARTF_USESHOWWINDOW
SI.wShowWindow = swWnd

If Len(cmdLine) > 0 Then
    If Left$(cmdLine, 1) <> " " Then
        cmdLine = " " & cmdLine
    End If
    Debug.Print ppath & cmdLine
    p = CreateProcess(ppath, cmdLine, 0&, 0&, 0&, NORMAL_PRIORITY_CLASS, 0&, workDir, SI, PI)
Else
    Debug.Print ppath
    p = CreateProcess(vbNullString, ppath$, 0&, 0&, 0&, NORMAL_PRIORITY_CLASS, 0&, workDir, SI, PI)
End If

If p <> 0 Then
    WaitForSingleObject PI.hProcess, INFINITE
    CloseHandle PI.hProcess
    CloseHandle PI.hThread
Else
    MsgBox "Error LaunchAndWait code = " & GetLastError()
End If

Exit Sub
errLW:
Debug.Print Err.Description
End Sub

Phishing: falsa notifica da Facebook


Dopo le false notifiche di Twitter, vi segnalo oggi una mail di spam che sfrutta la popolarità di Faebook per cercare di mostrarsi credibile.

La mail ha come oggetto "You have 4 lost messages on Facebook..." ed il mittente fittizio risulta essere notification+zkfebgklgyrn@notifierfacebook.com.

Ad una più attenta analisi dell'header possiamo individuare il vero mittente della mail, che risulta essere tale bimaculate@dynamicpipe.net, mentre il vero indirizzo puntato dai link non è ovviamente Facebook, bensì tale hxxp://hdwhc.com/medfield.html, che altro non è che un ponte verso il solito sito hxxp://www.pillscioffline.com della Canadian Family Pharmacy.

Tecnica usata e sito referente ci suggeriscono che gli autori sono gli stessi della falsa mail di notifica di Twitter.

Whois sul sito:

Domain Name:pillscioffline.com
Domain registrar_creation:2011-08-31 21:24:54
Domain registrar_expiration:2012-08-31 21:24:54
Domain registry_creation:2011-08-31 21:24:54
Domain registry_expiration:2012-08-31 21:24:54
Domain lastupdate:2011-10-04 16:11:43
Name Server:ns1.pillscioffline.com 61.133.234.105
Name Server:ns2.pillscioffline.com 202.100.91.132

Owner ID: FREE-ORG-513190
Owner Name: Amos Pizarro
Owner Organization: Amos Pizarro
Owner Street1: Constitucion 99
Owner City: Villaseco de los Gamitos
Owner Postal Code: 37114
Owner Country: SPAIN
Owner Phone: +34.735242344
Owner Email:

sabato 24 settembre 2011

Windows Installer Resiliency: disabilitarla per alcuni files


Lavorando sulla creazione di pacchetti di installazione per i mie progetti mi sono scontrato con una caratteristica importante, ma nello stesso fastidiosa di Windows Installer, meglio conosciuta come resiliency.
Essa è un meccanismo di autoriparazione del servizio Windows Installer che sorveglia i files del vostro programma e li ripristina nel caso qualcuno fosse stato cancellato per errore.
Detta così potrebbe sembrare una buona cosa, ma spesso può intralciare il lavoro del programmatore, specialmente in tutti quei casi dove è il programma stesso a dover cambiare nome o cancellare i files installati con il pacchetto.
L'escamotage che Microsoft ci propone per bypassare il meccanismo è quello di disabilitare il componente WI nel caso in cui esso ostacoli il nostro volere.
Non mi sembra però una buona soluzione, soprattutto per i grandi effetti collaterali, quindi è più opportuno inibire il controllo sui files per i quali vogliamo avere la massima libertà di operare.
Il meccanismo della resiliency si basa sul valore della chiave KeyPath di ogni componente del pacchetto e che rappresenta il collegamento logico fra esso ed il file fisico. Rendendolo nullo, quindi, avremo la possibilità di escludere il check sullo specifico componente.
Per fare ciò sarà sufficiente aprire il pacchetto MSI precedentemente creato con il vostro ambiente preferito con ORCA e osservare il contenuto di due tabelle, principalmente: Component e File.
Nella tabella Component trovate il campo KeyPath, ma l'intero contenuto risulata illegibile a causa degli identificativi numerici usati. Per avere l'esatta corrispondenza fra il valore di KeyPath ed il nome del file dobbiamo avvalerci della tab File, come evidenziato nelle due immagini di seguito


Cancellare il valore di KeyPath nei componenti per i quali non desideriamo l'autorepair ci consentirà di liberarli dall'occhio vigile di Windows Installer

venerdì 16 settembre 2011

Phishing: una falsa notifica da twitter


Oltre alle altre email di spam già postate qui e qui, vorrei segnalare anche questo tentativo di phishing appena ricevuto.
La mail si presenta come una classica notifica di twitter, come si può vedere dalla foto dove si viene invitati dal team di Twitter a seguire il link indicato per visualizzare l'importante notifica.
Se non avete un account Twitter, probabilmente il tasto CANC è il primo che premerete, ma se invece siete iscritti a questo servizio di microblogging allora un primo sospetto dovrebbe manifestarsi immediatamente, perché non c'è nessuna notifica vera e propria ma solo un link per visitarla.
La conferma della truffa, invece, arriva vedendo il vero indirizzo internet verso cui la mail vuole farci andare.
Esso è (ho rinominato http in hxxp):
hxxp://jstempe0.j157.jwstemper.com/rudiment.html

Visitando il sito con le opportune cautele, cosa sconsiglio vivamente di fare a tutti, si verrà rediretti verso un sito di vendita di prodotti farmaceutici canadese, o almeno così si presenta, chiamato "Canadian Family Pharmacy" che, ovviamente, ha tra i prodotti in vetrina Cialis, Viagra e altre pillole per la "salute" dell'uomo. Il sito in oggetto è raggiungibile all'indirizzo hxxp://www.pillscioffline.com

Anche questa truffa è stata scoperta e voi mi raccomando, in guardia!

giovedì 15 settembre 2011

Nigerian Scam: ENGR.JERRY OKORO


Dopo lo spam alla libica , vi presento oggi una delle varianti del famoso Scam alla nigeriana.. 
Ovviamente questa mail è un falso alla quale non bisogna né rispondere, né rispondere fornendo i dati richiesti!
 
REQUEST FOR URGENT ACCOUNT

I am ENGR.JERRY OKORO of  Nigeria National Petroleum Corporation (NNPC),I head a seven man Tenders
Board Committee in charge of contract award and Payment approvals.I came to know of you in my search for a reliable and reputable person To handle a very
confidential transaction,which involves the transfer of a huge sum of money to your Bank account.There were series of contracts executed by a consortium of
Multinationals in the oil industry in favour of the (NNPC) among which were;

1) The expansion of Pipeline network within Nigeria for crude oil and downstream products distribution and subsequent evacuation - US$2 Billion.
2) Contract for Turn Around Maintenance (TAM) of various Refineries in the country.
3) The construction of Storage Tanks for Petroleum Product (Depots)-US$94 Million.The original value of of these contracts were deliberately over
invoiced In the sum of  forty Million United States Dollars US$40,000,000.00) which has recently been approved and now ready To be
transferred. However the companies that actually executed the aforementioned contract have been fully paid and the projects officially commissioned. I am
writing you so that YOU will assist us with a foreign bank account where we can pay the money into.We have prepare every documentations that will assist you or
your company as the contractor that executed the contract with our ministry.The money will be released to your account within short period of days after we have
filed in all your informations which you will provide.I will like you to acknowledge the receipt of this e-mail as soon as possible via my contacts
above with the following informations:

(1) YOUR FULL NAME....................................
(2) HOME OR OFFICE ADDRESS................................
(3) YOUR PHONE & FAX NUMBER...................
(4) BANK ACCOUNT DETAILS...................................

I look forward to your quick reply so i can furnish you with more details of this deal.

NOTE :THE SHARRING MODALITY:65% OF THE FUNDS IS FOR ME THE ORIGINATOR OF THE BUSINESS AND 35% TO YOU FOR YOUR SERVICES AND PROVISION OF THE ACCOUNTS CO-ORDINATES.


BEST REGARDS,

ENGR.JERRY  OKORO
 
Received from: jcokoro@gmail.com 

mercoledì 7 settembre 2011

Spam alla libica: quando lo spam è aggiornato con la situazione politica

Volevo portare alla vostra attenzione alcune mail di spam che sfruttano la situazione libica per tentare di attirare la vostra attenzione e fiducia.

Questa è la mail di spam che ho ricevuto:
<<
From: "Mr.Hameed Mahmoud"<hammodd@indiatimes.com>
Subject: CONTRACT SUPPLY NEEDED

Dear Sir/Ma,

To introduce our selves to you, we are transitional Government of Benghazi Libya
contract committee for contractors/suppliers/manufacturers exporters
representatives in Libya.
Presently we are actively engaged in sourcing for individuals, companies and
organizations to supply us with various goods and items for the reconstruction of
transitional Government of Benghazi Libya.
contract supply to the transitional Government of Benghazi Libya. we have been in
the line of business since reconstruction pledge was made,Our recent expansion and
desire to promote trade and industrial link as afforded us the opportunity
to contact you,for an urgent contract supply of various goods and items for
the transitional Government of Benghazi Libya.
if you can supply us with various items and goods do not hesitate to inform us by
mail,so we can direct you to our Offshore Recommendation Centre Based in the heart
of middle-east,for an urgent supply.
The O.S.R.C was setup because most of our suppliers find it hard travelling to Libya

to complete the contract fomalities because of the violence in the region. Looking
forward to hear from you.
All further response to this proposal should be communicated to this private
mail:hammod@indiatimes.com

Yours faithfully

Mr.Hameed Mahmoud
For: Transitional Committee Government Benghazi Libya
>>

Estremamente simpatico il fatto che appena qualche mese fa, il sedicente Mr.Hameed Mahmoud
inviava al mondo quest'altra mail:



<<

I am Mr.Hameed Mahmoud aide to Saif al-Islam Muammar Al-Gaddafi,son to the
Libyan President.
I am urgently in need of your assistance and commitment on this Business
that will benefit both of us.Due to the unfortunate crisis happening in my
Country(Libya) and the attempt to remove his father,we have decicded to
transfer our total money immediately before the crisis get more worse.
If you are interested and willing to be of assistance and support, then
contact me back for more details.

Thank you for your understanding.

Yours in Allah,

Mr.Hameed Mahmoud

Aide to Saif al-Islam Muammar Al-Gaddafi (Son Libyan President)

>>

Deve essere veramente cambiata la situazione in Libia se anche gli spammer si sono adeguati!!