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