-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathuseraccessfetch.php
138 lines (130 loc) · 5.98 KB
/
useraccessfetch.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
include_once("connection.php");
include_once("function.php");
include_once("configfetch.php");
$pattern = "%";
$tsql = "SELECT hu.huntingGUID,
sa.serverName serverName
,[strategy]
,[securityParameter]
FROM [NOAH].[dbo].[OSPrivilegeAudited] tableInf, [NOAH].[dbo].[ServerAudited] sa, [NOAH].[dbo].[Hunt] hu
WHERE tableInf.serverID = sa.serverID
AND hu.huntingID = sa.huntingID
$sqlFilter
AND securityParameter LIKE '%".$pattern."%'
";
$getUserAccess = sqlsrv_query($conn, $tsql);
if ( $getUserAccess === false)
die( print_r( sqlsrv_errors(), true));
$data = array();
$data['data'] = '';
if(sqlsrv_has_rows($getUserAccess)) {
while( $row = sqlsrv_fetch_array( $getUserAccess, SQLSRV_FETCH_ASSOC)) {
echo '<tr><td>'.$row['huntingGUID'].'</td><td>'.$row['serverName'].'</td><td><b>OS Privileges</b> '.$row['strategy'].'</td><td>'.$row['securityParameter'].'</td></tr>';
//echo '<tr><td>'.$row['serverName'].'</td><td>'.$row['MD5'].'</td><td>'.$row['LaunchString'].'</td><td>'.$row['Signer'].'</td></tr>';
}
}
$tsql = "SELECT hu.huntingGUID,
sa.serverName serverName
,[account]
,sha.[shareName]
FROM [NOAH].[dbo].[ShareRightsAudited] tableInf, [NOAH].[dbo].[ShareAudited] sha, [NOAH].[dbo].[ServerAudited] sa, [NOAH].[dbo].[Hunt] hu
WHERE sha.serverID = sa.serverID
AND hu.huntingID = sa.huntingID
$sqlFilter
AND tableInf.shareAuditedID = sha.shareAuditedID
AND account LIKE '%".$pattern."%'
";
$getUserAccess = sqlsrv_query($conn, $tsql);
if ( $getUserAccess === false)
die( print_r( sqlsrv_errors(), true));
if(sqlsrv_has_rows($getUserAccess)) {
while( $row = sqlsrv_fetch_array( $getUserAccess, SQLSRV_FETCH_ASSOC)) {
echo '<tr><td>'.$row['huntingGUID'].'</td><td>'.$row['serverName'].'</td><td><b>Share</b> '.$row['shareName'].'</td><td>'.$row['account'].'</td></tr>';
//echo '<tr><td>'.$row['serverName'].'</td><td>'.$row['MD5'].'</td><td>'.$row['LaunchString'].'</td><td>'.$row['Signer'].'</td></tr>';
}
}
$tsql = "SELECT hu.huntingGUID,
sa.serverName serverName
,[runAs]
,Name
,ScheduledAction
,arguments
FROM [NOAH].[dbo].[ScheduledTaskAudited] tableInf, [NOAH].[dbo].[ServerAudited] sa, [NOAH].[dbo].[Hunt] hu
WHERE tableInf.serverID = sa.serverID
AND hu.huntingID = sa.huntingID
$sqlFilter
AND runAs LIKE '%".$pattern."%'
";
$getUserAccess = sqlsrv_query($conn, $tsql);
if ( $getUserAccess === false)
die( print_r( sqlsrv_errors(), true));
if(sqlsrv_has_rows($getUserAccess)) {
while( $row = sqlsrv_fetch_array( $getUserAccess, SQLSRV_FETCH_ASSOC)) {
echo '<tr><td>'.$row['huntingGUID'].'</td><td>'.$row['serverName'].'</td><td><b>Scheduled Task</b> '.$row['Name'].' ('.$row['ScheduledAction'].' - '.$row['arguments'].')</td><td>'.$row['runAs'].'</td></tr>';
//echo '<tr><td>'.$row['serverName'].'</td><td>'.$row['MD5'].'</td><td>'.$row['LaunchString'].'</td><td>'.$row['Signer'].'</td></tr>';
}
}
$tsql = "SELECT hu.huntingGUID,
sa.serverName serverName
,[username]
,tableInf.domain
,Name
,CommandLine
FROM [NOAH].[dbo].[ProcessTreeAudited] tableInf, [NOAH].[dbo].[ServerAudited] sa, [NOAH].[dbo].[Hunt] hu
WHERE tableInf.serverID = sa.serverID
AND hu.huntingID = sa.huntingID
$sqlFilter
AND username LIKE '%".$pattern."%'
";
$getUserAccess = sqlsrv_query($conn, $tsql);
if ( $getUserAccess === false)
die( print_r( sqlsrv_errors(), true));
if(sqlsrv_has_rows($getUserAccess)) {
while( $row = sqlsrv_fetch_array( $getUserAccess, SQLSRV_FETCH_ASSOC)) {
$launchStringTruncated = truncateForceLength($row['CommandLine'],80);
echo '<tr><td>'.$row['huntingGUID'].'</td><td>'.$row['serverName'].'</td><td><b>Process</b> '.$row['Name'].' ('.$launchStringTruncated.')</td><td>'.$row['domain'].'\\'.$row['username'].'</td></tr>';
//echo '<tr><td>'.$row['serverName'].'</td><td>'.$row['MD5'].'</td><td>'.$row['LaunchString'].'</td><td>'.$row['Signer'].'</td></tr>';
}
}
$tsql = "SELECT hu.huntingGUID,
sa.serverName serverName
,[UserName]
,[MRU]
FROM [NOAH].[dbo].[RunMRUsAudited] tableInf, [NOAH].[dbo].[ServerAudited] sa, [NOAH].[dbo].[Hunt] hu
WHERE tableInf.serverID = sa.serverID
AND hu.huntingID = sa.huntingID
$sqlFilter
AND UserName LIKE '%".$pattern."%'
";
$getUserAccess = sqlsrv_query($conn, $tsql);
if ( $getUserAccess === false)
die( print_r( sqlsrv_errors(), true));
if(sqlsrv_has_rows($getUserAccess)) {
while( $row = sqlsrv_fetch_array( $getUserAccess, SQLSRV_FETCH_ASSOC)) {
echo '<tr><td>'.$row['huntingGUID'].'</td><td>'.$row['serverName'].'</td><td><b>MRU</b> '.$row['MRU'].'</td><td>'.$row['UserName'].'</td></tr>';
//echo '<tr><td>'.$row['serverName'].'</td><td>'.$row['MD5'].'</td><td>'.$row['LaunchString'].'</td><td>'.$row['Signer'].'</td></tr>';
}
}
$tsql = "SELECT hu.huntingGUID,
sa.serverName serverName
,[UserName]
,[Unicode_Link_Name]
FROM [NOAH].[dbo].[RecentDocsAudited] tableInf, [NOAH].[dbo].[ServerAudited] sa, [NOAH].[dbo].[Hunt] hu
WHERE tableInf.serverID = sa.serverID
AND hu.huntingID = sa.huntingID
$sqlFilter
AND username LIKE '%".$pattern."%'
";
$getUserAccess = sqlsrv_query($conn, $tsql);
if ( $getUserAccess === false)
die( print_r( sqlsrv_errors(), true));
if(sqlsrv_has_rows($getUserAccess)) {
while( $row = sqlsrv_fetch_array( $getUserAccess, SQLSRV_FETCH_ASSOC)) {
echo '<tr><td>'.$row['huntingGUID'].'</td><td>'.$row['serverName'].'</td><td><b>Recent Docs</b> '.$row['Unicode_Link_Name'].'</td><td>'.$row['UserName'].'</td></tr>';
//echo '<tr><td>'.$row['serverName'].'</td><td>'.$row['MD5'].'</td><td>'.$row['LaunchString'].'</td><td>'.$row['Signer'].'</td></tr>';
}
}
echo '<tr><td><br>';
//echo paginate_function($item_per_page, $page_number, $total, $total_pages);
echo '</td></tr>';