@corellium/corellium-cli 1.3.8 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" ?>
2
2
  <!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
3
- <coverage lines-valid="0" lines-covered="0" line-rate="NaN" branches-valid="0" branches-covered="0" branch-rate="NaN" timestamp="1729701253977" complexity="0" version="0.1">
3
+ <coverage lines-valid="0" lines-covered="0" line-rate="NaN" branches-valid="0" branches-covered="0" branch-rate="NaN" timestamp="1736549777655" complexity="0" version="0.1">
4
4
  <sources>
5
5
  <source>/builds/middleware/corellium-cli</source>
6
6
  </sources>
@@ -86,7 +86,7 @@
86
86
  <div class='footer quiet pad2 space-top1 center small'>
87
87
  Code coverage generated by
88
88
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
89
- at 2024-10-23T16:34:13.985Z
89
+ at 2025-01-10T22:56:17.672Z
90
90
  </div>
91
91
  <script src="prettify.js"></script>
92
92
  <script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corellium/corellium-cli",
3
- "version": "1.3.8",
3
+ "version": "1.4.0",
4
4
  "description": "Corellium CLI Tool",
5
5
  "scripts": {
6
6
  "corellium": "node index.js",
@@ -33,6 +33,11 @@ async function builder (yargs) {
33
33
  describe: 'Project ID to associate with instance',
34
34
  demandOption: true
35
35
  })
36
+ .option('os-build', {
37
+ type: 'string',
38
+ describe: 'OS Build',
39
+ demandOption: false
40
+ })
36
41
  .option('name', {
37
42
  type: 'string',
38
43
  describe: 'Optional name of instance',
@@ -43,6 +48,18 @@ async function builder (yargs) {
43
48
  describe: 'Wait for the instance to be ready',
44
49
  demandOption: false
45
50
  })
51
+ .option('dyld-aslr', {
52
+ type: 'boolean',
53
+ describe: 'Enable ASLR for DYLD Shared Cache. (--no-dyld-aslr to disable)',
54
+ default: true,
55
+ demandOption: false
56
+ })
57
+ .option('app-aslr', {
58
+ type: 'boolean',
59
+ describe: 'Enable ASLR for Applications. (--no-app-aslr to disable)',
60
+ default: true,
61
+ demandOption: false
62
+ })
46
63
  }
47
64
 
48
65
  async function handler (argv) {
@@ -51,9 +68,34 @@ async function handler (argv) {
51
68
  const project = argv.project
52
69
  const name = argv.name
53
70
  const api = await getApi()
71
+ const bootOptions = {}
72
+ const additionalTags = []
73
+ const instanceOptions = { flavor, os, project, name }
74
+
75
+ if (argv['app-aslr'] === false) {
76
+ additionalTags.push('noappaslr')
77
+ }
78
+
79
+ if (argv['dyld-aslr'] === false) {
80
+ additionalTags.push('nodyldaslr')
81
+ }
82
+
83
+ // only define additional tags if any are present
84
+ if (additionalTags.length > 0) {
85
+ bootOptions.additionalTags = additionalTags
86
+ }
87
+
88
+ // only define bootOptions if it contains any values
89
+ if (Object.keys(bootOptions).length > 0) {
90
+ instanceOptions.bootOptions = bootOptions
91
+ }
92
+
93
+ if (argv['os-build']) {
94
+ instanceOptions.osbuild = argv['os-build']
95
+ }
54
96
 
55
97
  try {
56
- const instance = await api.v1CreateInstance({ flavor, os, project, name })
98
+ const instance = await api.v1CreateInstance(instanceOptions)
57
99
  // Wait 360 attempts for the instance to be created (30 minutes)
58
100
  if (argv.wait) {
59
101
  await waitForState(instance.id, api.v1GetInstance.bind(api), 'on', 360)
@@ -1,7 +1,8 @@
1
1
  const subcommands = [
2
2
  require('./create'),
3
3
  require('./list'),
4
- require('./delete')
4
+ require('./delete'),
5
+ require('./vpnConfig')
5
6
  ]
6
7
 
7
8
  let _yargs
@@ -0,0 +1,40 @@
1
+ const { handleError } = require('../../error')
2
+ const fs = require('fs')
3
+ const fsp = fs.promises
4
+ const { getCorelliumApi } = require('../../corellium-api')
5
+
6
+ async function builder (yargs) {
7
+ yargs.option('verbose', {
8
+ alias: 'v',
9
+ type: 'boolean',
10
+ describe: 'Console will receive verbose error output'
11
+ }).option('project', {
12
+ type: 'input',
13
+ describe: 'Id of the project to pull ovpn configuration from.',
14
+ string: true
15
+ }).option('path', {
16
+ type: 'input',
17
+ describe: 'Path to where to save the ovpn configuration file.',
18
+ string: true
19
+ })
20
+ }
21
+
22
+ async function handler (argv) {
23
+ const project = argv.project
24
+ const corellium = await getCorelliumApi()
25
+ const projectApi = await corellium.getProject(project)
26
+ const savePath = argv.path
27
+ try {
28
+ const vpnConfigBuffer = await projectApi.vpnConfig()
29
+ await fsp.writeFile(savePath, vpnConfigBuffer.toString())
30
+ } catch (err) {
31
+ handleError(err, 'vpnConfig failed', argv.verbose)
32
+ }
33
+ }
34
+
35
+ module.exports = {
36
+ builder,
37
+ handler,
38
+ command: 'vpnConfig [project] [path]',
39
+ describe: 'Download Openvpn config for a project'
40
+ }
package/test/test.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const { exec } = require('child_process')
2
2
  const { promisify } = require('util')
3
+ const fs = require('fs')
3
4
  const path = require('path')
4
5
  const execp = promisify(exec)
5
6
  const assert = require('node:assert').strict
@@ -10,6 +11,7 @@ test()
10
11
  async function test () {
11
12
  await testProjects()
12
13
  await testInstances()
14
+ await testProjectGetOvpnConfig()
13
15
  }
14
16
 
15
17
  async function testInstances () {
@@ -44,6 +46,20 @@ async function testProjects () {
44
46
  assert.equal(-1, projects.map(p => p.id).indexOf(projectId))
45
47
  }
46
48
 
49
+ async function testProjectGetOvpnConfig () {
50
+ const projects = (await ej('project list'))
51
+ const defaultProject = projects.find((p) => p.name === 'Default Project')
52
+ assert.ok(defaultProject)
53
+
54
+ const instanceId = (await e(`instance create ranchu 12.0.0 ${defaultProject.id}`))
55
+ assert.ok(instanceId)
56
+
57
+ await e(`project vpnConfig ${defaultProject.id} ./test/test.ovpn`)
58
+ assert.ok(fs.existsSync('./test/test.ovpn'))
59
+
60
+ await e(`instance delete ${instanceId}`)
61
+ }
62
+
47
63
  async function sleep (ms) {
48
64
  return new Promise((resolve) => setTimeout(resolve, ms))
49
65
  }