To rebuild a SQL 2005 master database:
start /wait setup.exe /qn
INSTANCENAME= REINSTALL=SQL_Engine
REBUILDDATABASE=1 SAPWD=
In SQL 2008 use:
setup.exe
/QUIET
/ACTION=REBUILDDATABASE
/INSTANCENAME=instance_name
/SQLSYSADMINACCOUNTS= accounts
[/SAPWD=password]
[/SQLCOLLATION=collation_name]
Then start in single user mode:
sqlservr.exe -m -s
Then restore the latest backup of master and user databases, bringing the instance to the latest point possible.
More Info:
http://www.sqlservercentral.com/articles/Administration/73207/
http://www.networkworld.com/community/node/39292