Skip to content

Commit 496b1f8

Browse files
committed
Add JD2 EventScripter RCE examples
1 parent a3f52c0 commit 496b1f8

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

jdownloader/ArchiveExtracted.RCE.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
var node = 'http://username:[email protected]:5452/command'
2+
var output = '/path/to/Media'
3+
4+
var package = archive.getDownloadLinks() ? archive.getDownloadLinks()[0].getPackage() : null
5+
var links = package ? package.getDownloadLinks() : []
6+
7+
function isReallyFinished() {
8+
for (var i = 0; i < links.length; i++) {
9+
if (links[i].getArchive() != null && links[i].getExtractionStatus() != "SUCCESSFUL" || !package.isFinished()) {
10+
return false
11+
}
12+
}
13+
return true
14+
}
15+
16+
if (package && isReallyFinished()) {
17+
var path = package.getDownloadFolder()
18+
var name = package.getName()
19+
var label = package.getComment() ? package.getComment() : 'N/A'
20+
21+
var filebot = ['-script', 'fn:amc', '--output', output, '--action', 'duplicate', '--conflict', 'skip', '-non-strict', '--log-file', 'amc.log', '--def', 'skipExtract=y', 'unsorted=y', 'music=y', 'artwork=y', 'excludeList=.excludes', '--def', 'ut_dir=' + path, 'ut_kind=multi', 'ut_title=' + name, 'ut_label=' + label]
22+
var curl = ['curl', node, '--header', 'Content-Type: application/json', '--data', JSON.stringify(filebot)]
23+
log(curl)
24+
log(callSync(curl))
25+
}

jdownloader/ArchiveExtracted.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ function isReallyFinished() {
1313
}
1414

1515
if (package && isReallyFinished()) {
16-
var command = [script, package.getDownloadFolder(), package.getName(), package.getComment() ? package.getComment() : 'N/A', 'ARCHIVE_EXTRACTED']
16+
var path = package.getDownloadFolder()
17+
var name = package.getName()
18+
var label = package.getComment() ? package.getComment() : 'N/A'
19+
20+
var command = [script, path, name, label, 'ARCHIVE_EXTRACTED']
1721
log(command)
1822
log(callSync(command))
1923
}

jdownloader/PackageFinished.RCE.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var node = 'http://username:[email protected]:5452/command'
2+
var output = '/path/to/Media'
3+
4+
var path = package.getDownloadFolder()
5+
var name = package.getName()
6+
var label = package.getComment() ? package.getComment() : 'N/A'
7+
var links = package.getDownloadLinks() ? package.getDownloadLinks() : []
8+
9+
function isReallyFinished() {
10+
for (var i = 0; i < links.length; i++) {
11+
if (links[i].getArchive() != null && links[i].getExtractionStatus() != "SUCCESSFUL" || !package.isFinished()) {
12+
return false
13+
}
14+
}
15+
return true
16+
}
17+
18+
if (isReallyFinished()) {
19+
var filebot = ['-script', 'fn:amc', '--output', output, '--action', 'duplicate', '--conflict', 'skip', '-non-strict', '--log-file', 'amc.log', '--def', 'skipExtract=y', 'unsorted=y', 'music=y', 'artwork=y', 'excludeList=.excludes', '--def', 'ut_dir=' + path, 'ut_kind=multi', 'ut_title=' + name, 'ut_label=' + label]
20+
var curl = ['curl', node, '--header', 'Content-Type: application/json', '--data', JSON.stringify(filebot)]
21+
log(curl)
22+
log(callSync(curl))
23+
}

0 commit comments

Comments
 (0)