@@ -126,7 +126,7 @@ bool ForkChecker::PreCheck(sp::SpPoint* pt, sp::SpFunction* callee) {
126
126
bool ForkChecker ::PostCheck (sp ::PointCallHandle * pHandle ) {
127
127
sp ::SpFunction * callee = pHandle -> GetCallee ();
128
128
if (callee -> name ().compare ("fork" ) == 0 ) {
129
- pid_t ret = (pid_t ) pHandle -> GetReturnValue ();
129
+ pid_t ret = (pid_t )pHandle -> GetReturnValue ();
130
130
if (ret == 0 ) {
131
131
mgr_ -> NewDoc ();
132
132
} else {
@@ -144,4 +144,53 @@ bool ForkChecker::PostCheck(sp::PointCallHandle* pHandle) {
144
144
return true;
145
145
}
146
146
147
- } // namespace mist
147
+ bool FileChecker ::PreCheck (sp ::SpPoint * pt , sp ::SpFunction * callee ) {
148
+ if (callee -> name () == "open" || callee -> name () == "fopen" ) {
149
+ sp ::ArgumentHandle h ;
150
+ char * * fname = (char * * )PopArgument (pt , & h , sizeof (void * ));
151
+ CallTrace newTrace ;
152
+ newTrace .functionName = callee -> name ();
153
+ newTrace .timeStamp = std ::to_string (FpvaUtils ::GetUsec ());
154
+ newTrace .parameters .insert (
155
+ std ::pair < std ::string , std ::string > ("file" , std ::string (* fname )));
156
+ mgr_ -> AddTrace (& newTrace );
157
+ return true;
158
+ } else if (callee -> name () == "chmod" ) {
159
+ sp ::ArgumentHandle h ;
160
+ char * * fname = (char * * )PopArgument (pt , & h , sizeof (void * ));
161
+ mode_t * mode = (mode_t * )PopArgument (pt , & h , sizeof (mode_t ));
162
+ CallTrace newTrace ;
163
+ newTrace .functionName = callee -> name ();
164
+ newTrace .timeStamp = std ::to_string (FpvaUtils ::GetUsec ());
165
+ newTrace .parameters .insert (
166
+ std ::pair < std ::string , std ::string > ("file" , std ::string (* fname )));
167
+ newTrace .parameters .insert (
168
+ std ::pair < std ::string , std ::string > ("mode" , std ::to_string (* mode )));
169
+ mgr_ -> AddTrace (& newTrace );
170
+ return true;
171
+ }
172
+ return false;
173
+ }
174
+
175
+ bool FileChecker ::PostCheck (sp ::PointCallHandle * ) { return true; }
176
+
177
+ bool PrivilegeChecker ::PreCheck (sp ::SpPoint * pt , sp ::SpFunction * callee ) {
178
+ if (callee -> name () == "seteuid" || callee -> name () == "setuid" ) {
179
+ sp ::ArgumentHandle h ;
180
+ uid_t * uid = (uid_t * )PopArgument (pt , & h , sizeof (uid_t ));
181
+ CallTrace newTrace ;
182
+ newTrace .functionName = callee -> name ();
183
+ newTrace .timeStamp = std ::to_string (FpvaUtils ::GetUsec ());
184
+ newTrace .parameters .insert (std ::pair < std ::string , std ::string > (
185
+ "name" , FpvaUtils ::GetUserName (* uid )));
186
+ newTrace .parameters .insert (
187
+ std ::pair < std ::string , std ::string > ("uid" , std ::to_string (* uid )));
188
+ mgr_ -> AddTrace (& newTrace );
189
+ return true;
190
+ }
191
+ return false;
192
+ }
193
+
194
+ bool PrivilegeChecker ::PostCheck (sp ::PointCallHandle * ) { return true; }
195
+
196
+ } // namespace fpva
0 commit comments