Skip to content

Commit 7a0c77b

Browse files
authored
Merge pull request #103 from DC3-DCCI/master
Add PyCharm Instructions
2 parents 0ab96d2 + aba8d3d commit 7a0c77b

12 files changed

Lines changed: 91 additions & 0 deletions

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ Key features:
4747
* `decode -d <decoder> <pcap>`
4848
* Run the selected decoder on a pcap file
4949

50+
## Development
51+
* [Using Dshell With PyCharm](doc/UsingDshellWithPyCharm.md)
52+
5053
## Partners
5154

5255
Below are repositories from partners Dshell has worked together with.

doc/UsingDshellWithPyCharm.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Using DShell with PyCharm
2+
3+
This document will outline how Dshell decoders and the framework itself can be setup to allow development and
4+
debugging within the Python IDE, PyCharm. If preferred, the concepts can likely be translated to other IDE’s and debugging environments.
5+
6+
After first installing all prerequistes mentioned in the [README](../README.md) and then opening the source repository
7+
in Pycharm, the following needs to be done in order for PyCharm to correctly recognize the Dshell source code and executables.
8+
9+
10+
## Settings
11+
12+
### Project Structure
13+
In order to properly use PyCharm with Dshell, we need to tell it where to find the relevant Python files.
14+
Under `File -> Settings -> Project: DShell -> Project Structure` set the folders `bin`, `decoders`, `lib`, and `lib/output`
15+
as sources. Then click OK. After a few seconds, you should now see all the red underlines on imports disappear.
16+
17+
![](image1.png)
18+
19+
### Project Interpreter
20+
We also need to tell the Python interpreter where to find the relevant files. This is useful if you want to import
21+
Dshell modules within the interpreter. Under `File -> Settings -> Project: DShell -> Project Interpreter` click the
22+
gear icon next to the dropdown with the project interpreter you are going to use, and then select `More…`
23+
24+
![](image2.png)
25+
26+
Then with your current Python interpreter highlighted, click the small folder tree icon (below the filter icon) to see a
27+
window of `Interpreter Paths`. In this window click the `+` icon to the right and add the four folders added earlier
28+
(`bin`, `decoders`, `lib`, and `lib/output`).
29+
30+
![](image3.png)
31+
32+
You should now be able to import decoders and other Dshell modules using the built in Python interpreter.
33+
34+
![](image4.png)
35+
36+
37+
## Run Configurations
38+
Run configurations in PyCharm allow a user to specify how to run tasks and programs. In the context of Dshell, a
39+
configuration can be setup to specify which decoder to run, how to setup the environment variables needed by Dshell, and what working directory to use.
40+
41+
### Opening Configurations
42+
The first step within PyCharm is to open up the interface to edit configurations. This can be done through the toolbar as
43+
shown below or by using the menu to navigate to `Run -> Edit Configurations…`
44+
45+
![](image5.png)
46+
47+
### Adding a New Python Configuration for Dshell
48+
Once the configurations interface is open, the next step is to add a new configuration. Since Dshell utilizes Python, a
49+
Python configuration needs to be created. Select the `+` symbol near the top left and select `Python` in the drop down menu.
50+
51+
![](image6.png)
52+
53+
### Specifying the Configuration Details
54+
Now that the configuration window is open, the following fields need to be populated:
55+
56+
- Script: The full path to the `decode.py` script in Dshell.
57+
- Script parameters: The parameters that would be passed in when running the decode command.
58+
- Environment variables: The environment variables found in the `.dshellrc` file in Dshell’s root directory. This is detailed more below.
59+
- Working directory: If all the settings use absolute paths, the working directory can be set to anything. Setting the working directory to a location where output files should be placed is a reasonable option.
60+
61+
![](image7.png)
62+
63+
### Specifying the Environment Variables
64+
The environment variables in the configuration are important to mirror the Dshell shell.
65+
66+
When first running Dshell, some of the first steps are to build the project using make and to run the "dshell" script.
67+
The build step is relevant here because it produces the `.dshellrc` file that the "dshell" script depends on to configure the shell’s environment.
68+
69+
For the PyCharm configuration, open up the `.dshellrc` file in Dshell’s directory and take a look at the environment
70+
variables. Use these values to set the `Environment variables` field in the configuration.
71+
72+
![](image8.png)
73+
74+
### Save the Configuration
75+
Now that the configuration has been setup, just give it a name and hit OK.
76+
77+
78+
## Debugging
79+
80+
### Select Your Configuration
81+
Before debugging, make sure the configuration you want is selected.
82+
83+
![](image9.png)
84+
85+
### Start Debugging
86+
Once the configuration is set, make sure to set any breakpoints. Then, start up the debugger. Further details on how to use the debugger can be found online.
87+
88+
![](image10.png)

doc/image1.png

80.6 KB
Loading

doc/image10.png

37.2 KB
Loading

doc/image2.png

57.9 KB
Loading

doc/image3.png

107 KB
Loading

doc/image4.png

31.7 KB
Loading

doc/image5.png

48.8 KB
Loading

doc/image6.png

61.7 KB
Loading

doc/image7.png

102 KB
Loading

0 commit comments

Comments
 (0)