Registrations to Open-AudIT forums are now closed. To ask any new questions please visit Opmantek Community Questions.

Open-AudIT

What's on your network?
It is currently Thu Apr 18, 2024 5:59 pm

All times are UTC + 10 hours




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
 Post subject: Mac OS X Audit
PostPosted: Tue Sep 19, 2006 7:25 am 
Offline
Contributor

Joined: Fri Jul 14, 2006 1:16 am
Posts: 151
Location: Iowa
Any chance of a Mac OS X Audit script? Is it similar enough to Linux that it could be converted?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Sep 19, 2006 7:57 am 
Offline
Newbie

Joined: Sun Sep 17, 2006 4:43 am
Posts: 15
I'm trying this too... some of the audit_linux.sh stuff is working, but lspci for example does not work.

It could be possible to use an AppleScript to gather the information and paste it into the browser... i spent two hours this evening with that ;)

I'll post any progress that im making...
If you have any knowledge of the system info command in AppleScript, let me know :)

mfg
Dennis


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Sep 22, 2006 11:53 pm 
Offline
Newbie

Joined: Wed May 25, 2005 5:11 am
Posts: 49
Location: Toronto, Ontario, Canada
[quote="erSitzt"]I'm trying this too... some of the audit_linux.sh stuff is working, but lspci for example does not work.

It could be possible to use an AppleScript to gather the information and paste it into the browser... i spent two hours this evening with that ;)

I'll post any progress that im making...
If you have any knowledge of the system info command in AppleScript, let me know :)

mfg
Dennis


I'd started this too when I supported macs in my last job. Unfortunately I don't have any of the code but the approach I was looking at involved using ssh to run a shell script remotely that would use the system_profiler command (since you can have it output XML which can then be parsed with Perl or Python). I don't currently have access to a mac now unfortunately. I notice now there's a Perl extension that does this too:
http://cpan.uwinnipeg.ca/htdocs/Mac-Sys ... le.pm.html

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Sep 23, 2006 4:18 am 
Offline
Newbie

Joined: Sun Sep 17, 2006 4:43 am
Posts: 15
Nice ! I'll test it :)

mfg
Dennis


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Sep 25, 2006 6:33 am 
Offline
Newbie

Joined: Sun Sep 17, 2006 4:43 am
Posts: 15
Seems to work :)
I'll finish a perl script to audit mac and post my results.

mfg
Dennis


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Apr 20, 2007 12:45 am 
Offline
Newbie

Joined: Thu Apr 19, 2007 1:04 am
Posts: 11
Location: Here
Any update on this? We've just been assigned the task of integrating MacOS X info with open-audit at work, so I could really use this.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri May 18, 2007 2:36 am 
Offline
Newbie

Joined: Thu Aug 24, 2006 4:28 am
Posts: 16
I messaged erSitzt and he said he wasn't working on it anymore so I decided to do it.

I hacked together an audit script using admin_pc_add_2.php from Open-AudIT and a Mac agent for OCS Inventory which can be found http://codejanitor.com/wp/2006/02/16/oc ... 0-released.

Before you run it, search the file for "CHANGEME" and replace all occurances with the suitable info for you.

I tried to put in comments where it seems necessary. But here's a warning that I'm not a PHP coder and I'm sure there's better ways to do it.

Mac Audit 0.0001: http://k-thx.com/~scott/mac_audit.zip

This zip contains the main audit.php script, the 2 scripts I used to make it, and the expect script (read below about it).

[code]
Usage:

php audit.php

or

php audit.php xmlprofile.spx
[/code]

For the first option you run it on the remote machine you want to audit. The second option can be run from any machine.

This script will get all the info from System Profiler and populate the Open-Audit database.

Currently, lots of hardware is left out. I have no need for all of it so it isn't included right now. Feel free to modify it and add in whatever you want. It isn't very hard once you understand how it works; it's just tedious.

The next problem is running this script on all your Macs without a lot of manual work. The solution I came up with is this:

1. Enable SSH on all Macs
2. Add an admin user with the same name/pass on all Macs
3. Host audit.php on a local webserver
4. Use expect (apt-get install expect on ubuntu/debian) to execute the script on all machines

Here are some resources on expect or another great tool called tentakel (need to use SSH keys):

http://blog.platinumsolutions.com/node/135
http://www.cyberciti.biz/tips/execute-c ... rt-ii.html

Here is the script I use:

[code]
#!/usr/bin/expect -f
proc doWork {host} {
spawn ssh user@$host "curl http://url/audit.txt > audit.php;php audit.php;rm audit.php"
expect -timeout 5 -nocase "password: "
send "password"
send "\n"
send "exit\n"
expect -re "Connection.*closed\."
wait
}
set fp [open macs.txt r]
while {[gets $fp line] > -1} {
set host [string trim $line]
if {![string match "#*" $host] &&
[string length $host]} {
doWork $host
}
}
close $fp
[/code]

macs.txt is just a list of IPs. Add audit.exp to a cronjob and you're good to go.

Someone may want to integrate this into open-audit somehow.

I'm probably forgetting some stuff so ask away.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri May 18, 2007 2:47 am 
Offline
Newbie

Joined: Thu Aug 24, 2006 4:28 am
Posts: 16
I should say what is working right now:

Most basic system info
OS info
Software
Processor
Network Card
Memory


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Jun 14, 2007 2:57 am 
Offline
Newbie

Joined: Thu Apr 19, 2007 1:04 am
Posts: 11
Location: Here
Thanks Scott,

I will definately be looking into this and seeing if I can get it to work, although I am no unix or mac scripting expert by any stretch.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC + 10 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group