Created
November 23, 2011 23:35
-
-
Save acidprime/1390248 to your computer and use it in GitHub Desktop.
Basic Little Script to Add Usernames & Passwords via command line arguments to a mobileconfig 802.1X profiles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python -tt | |
__author__ = 'Zack Smith @acidprime' | |
__version__ = '0.1' | |
import sys | |
import getopt | |
import plistlib | |
global debugEnabled | |
global plist | |
global userName | |
global newPass | |
global templateFile | |
global saveFile | |
debugEnabled = True | |
def main(): | |
if(debugEnabled): print 'Processing Arguments: ', sys.argv[1:] | |
options, remainder = getopt.getopt(sys.argv[1:], 'w:f:u:p:', ['username=', | |
'password=', | |
'write=', | |
'file=', | |
]) | |
for opt, arg in options: | |
if opt in ('-u', '--username'): | |
userName = arg | |
elif opt in ('-p', '--password'): | |
newPass = arg | |
elif opt in ('-w', '--write'): | |
saveFile = arg | |
elif opt in ('-f', '--file'): | |
templateFile = arg | |
# -f is .mobileconfig template, -w is path to modified file. | |
plist = plistlib.Plist.fromFile(templateFile) | |
# Note that this is hard coded for a single payload. | |
EAPClientConfiguration = plist['PayloadContent'][0]['EAPClientConfiguration'] | |
EAPClientConfiguration['UserName'] = userName | |
EAPClientConfiguration['UserPassword'] = newPass | |
plist.write(saveFile) | |
return 0 | |
if __name__ == "__main__": | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment