get-passwords-from-safari-v2.txt 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. > -- OPEN SAFARI. GOTO PREFERENCES. CLICK PASSWORDS TAB --
  2. -- THIS FIRST REPEAT SECTION IS JUST TO GET TO THE PASSWORDS SCREEN AND LOGIN TO ICLOUD --
  3. repeat 1 times
  4. tell application "Safari"
  5. activate
  6. delay 0.5
  7. tell application "System Events"
  8. -- Ensure Password Field Selected --
  9. keystroke tab
  10. delay 0.2
  11. -- Type your password for you --
  12. keystroke "PASSWORD"
  13. delay 0.2
  14. -- Hit enter to login --
  15. keystroke return
  16. delay 0.2
  17. end tell
  18. end tell
  19. end repeat
  20. -- START GRABBING PASSWORDS - SET REPEAT VALUE TO NUMBER OF PASSWORDS --
  21. set x to 1
  22. repeat while (x ≤ 207)
  23. -- Switch To Safari --
  24. tell application "Safari"
  25. activate
  26. delay 0.5
  27. tell application "System Events"
  28. -- Switch from search field to password list field (Only needs to be done once) --
  29. if (x = 1) then
  30. keystroke tab
  31. delay 0.2
  32. end if
  33. -- Select first password in list (Field selected. but nothing highlighted) --
  34. key code 125
  35. delay 0.2
  36. -- Open Right-click Menu --
  37. tell application process "Safari"
  38. set _selection to value of attribute "AXFocusedUIElement"
  39. tell _selection to perform action "AXShowMenu"
  40. end tell
  41. -- Down arrow once to choose/highlight "Copy Website" --
  42. key code 125
  43. delay 0.2
  44. -- Copy Website/URL data --
  45. keystroke return
  46. delay 0.2
  47. end tell
  48. end tell
  49. -- Switch To TextEdit
  50. tell application "TextEdit"
  51. activate
  52. delay 0.5
  53. tell application "System Events"
  54. -- Print a double quote --
  55. keystroke "\""
  56. delay 0.2
  57. -- Paste "Website/URL" data to text file --
  58. keystroke "v" using command down
  59. delay 0.2
  60. -- Print ending double quote and a comma for CSV --
  61. keystroke "\","
  62. delay 0.2
  63. -- Print a double quote --
  64. keystroke "\""
  65. delay 0.2
  66. -- Paste "Websites" data to text file again (For "Title" field in 1Password) --
  67. keystroke "v" using command down
  68. delay 0.2
  69. -- Print ending double quote and a comma for CSV --
  70. keystroke "\","
  71. delay 0.2
  72. end tell
  73. end tell
  74. -- Switch To Safari --
  75. tell application "Safari"
  76. activate
  77. delay 0.5
  78. tell application "System Events"
  79. -- Open Window containing "User Name", "Password" and "Websites" fields --
  80. keystroke return
  81. delay 0.2
  82. -- Move to "User Name" field --
  83. keystroke tab
  84. delay 0.2
  85. -- Copy data from "User Name" field --
  86. keystroke "c" using command down
  87. delay 0.2
  88. end tell
  89. end tell
  90. -- Switch To TextEdit --
  91. tell application "TextEdit"
  92. activate
  93. delay 0.5
  94. tell application "System Events"
  95. -- Print a double quote --
  96. keystroke "\""
  97. delay 0.2
  98. -- Paste "User Name" data to text file --
  99. keystroke "v" using command down
  100. delay 0.2
  101. -- Print ending double quote and a comma for CSV --
  102. keystroke "\","
  103. delay 0.2
  104. end tell
  105. end tell
  106. -- Switch To Safari --
  107. tell application "Safari"
  108. activate
  109. delay 0.5
  110. tell application "System Events"
  111. -- Move to "Password" field --
  112. keystroke tab
  113. delay 0.2
  114. -- Copy from "Password" field --
  115. keystroke "c" using command down
  116. delay 0.2
  117. end tell
  118. end tell
  119. -- Switch To TextEdit --
  120. tell application "TextEdit"
  121. activate
  122. delay 0.5
  123. tell application "System Events"
  124. -- Print a double quote --
  125. keystroke "\""
  126. delay 0.2
  127. -- Paste "Websites" data to text file --
  128. keystroke "v" using command down
  129. delay 0.2
  130. -- Print ending double quote and start a new line --
  131. keystroke "\""
  132. keystroke return
  133. end tell
  134. end tell
  135. -- Switch To Safari --
  136. tell application "Safari"
  137. activate
  138. delay 0.5
  139. tell application "System Events"
  140. -- Click "Done" button --
  141. keystroke return
  142. delay 0.2
  143. end tell
  144. end tell
  145. set x to (x + 1)
  146. end repeat
  147. end run