1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-01-02 11:36:22 +01:00

cleanup #get_column_info a bit

bcook showed me how to do this the way i originally
wanted to but didn't know how. This is much cleaner to read

MSP-12356
This commit is contained in:
David Maloney 2015-05-06 10:31:18 -05:00
parent df1181fe32
commit a8b4010ed0

View File

@ -77,40 +77,28 @@ JET_ERR find_first(jetState *ntdsState){
*/
JET_ERR get_column_info(jetState *ntdsState, ntdsColumns *accountColumns){
JET_ERR columnError;
const char attributeNames[][25] = {
"ATTm590045",
"ATTj590126",
"ATTq589983",
"ATTk590689",
"ATTq589876",
"ATTk589879",
"ATTk589984",
"ATTj589993",
"ATTk589914",
"ATTk589918",
"ATTm13",
"ATTj589832",
"ATTq589920",
"ATTr589970"
struct {
char *name;
JET_COLUMNDEF *column;
}columns[] = {
{ "ATTm590045", &accountColumns->accountName },
{ "ATTj590126", &accountColumns->accountType },
{ "ATTq589983", &accountColumns->accountExpiry },
{ "ATTk590689", &accountColumns->encryptionKey },
{ "ATTq589876", &accountColumns->lastLogon },
{ "ATTk589879", &accountColumns->lmHash },
{ "ATTk589984", &accountColumns->lmHistory },
{ "ATTj589993", &accountColumns->logonCount },
{ "ATTk589914", &accountColumns->ntHash },
{ "ATTk589918", &accountColumns->ntHistory },
{ "ATTm13", &accountColumns->accountDescription },
{ "ATTj589832", &accountColumns->accountControl },
{ "ATTq589920", &accountColumns->lastPasswordChange },
{ "ATTr589970", &accountColumns->accountSID }
};
JET_COLUMNDEF *columnDefs[] = {
&accountColumns->accountName,
&accountColumns->accountType,
&accountColumns->accountExpiry,
&accountColumns->encryptionKey,
&accountColumns->lastLogon,
&accountColumns->lmHash,
&accountColumns->lmHistory,
&accountColumns->logonCount,
&accountColumns->ntHash,
&accountColumns->ntHistory,
&accountColumns->accountDescription,
&accountColumns->accountControl,
&accountColumns->lastPasswordChange,
&accountColumns->accountSID,
};
for (int i = 0; i < 14; i++){
columnError = JetGetTableColumnInfo(ntdsState->jetSession, ntdsState->jetTable, attributeNames[i], columnDefs[i], sizeof(JET_COLUMNDEF), JET_ColInfo);
int countColumns = sizeof(columns) / sizeof(columns[0]);
for (int i = 0; i < countColumns; i++){
columnError = JetGetTableColumnInfo(ntdsState->jetSession, ntdsState->jetTable, columns[i].name, columns[i].column, sizeof(JET_COLUMNDEF), JET_ColInfo);
if (columnError != JET_errSuccess){
return columnError;
}