-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
951 additions
and
396 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
First off, thank you for considering contributing to NMapGUI. All together we can make this proyect big and really useful. | ||
First off, thank you for considering contributing to NMapGUI. All together we can make this project big and really useful. | ||
|
||
In order to report Issues, suggest Enhancements or ask questions, you can use the Issues tab. | ||
In order to report Issues, suggest Enhancements or ask Questions, you can use the Issues tab. | ||
|
||
However, if you have any code contribution, it should be fully tested and functional before it gets reviewed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.uniovi.nmapgui; | ||
|
||
import java.io.InputStream; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import javax.xml.bind.JAXBContext; | ||
import javax.xml.bind.JAXBException; | ||
import javax.xml.bind.Unmarshaller; | ||
|
||
import com.uniovi.nmapgui.executor.CommandExecutor; | ||
import com.uniovi.nmapgui.executor.CommandExecutorImpl; | ||
import com.uniovi.nmapgui.executor.CommandExecutorObserver; | ||
import com.uniovi.nmapgui.model.Command; | ||
import com.uniovi.nmapgui.model.Script; | ||
import com.uniovi.nmapgui.model.ScriptHelp; | ||
import com.uniovi.nmapgui.model.menu.Menu; | ||
|
||
public class InitialConfigurator implements CommandExecutorObserver{ | ||
|
||
private Map<String,List<Script>> scriptCategories = new HashMap<>(); | ||
private Menu menu; | ||
|
||
public Map<String, List<Script>> getScriptCategories() { | ||
return scriptCategories; | ||
} | ||
|
||
public void setScriptCategories(Map<String, List<Script>> scriptCategories) { | ||
this.scriptCategories = scriptCategories; | ||
} | ||
|
||
public Menu getMenu() { | ||
return menu; | ||
} | ||
|
||
public void setMenu(Menu menu) { | ||
this.menu = menu; | ||
} | ||
|
||
public void configure(){ | ||
|
||
try { | ||
loadMenu(); | ||
} catch (JAXBException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
Command command = new Command("--script-help all"); | ||
CommandExecutor executor = new CommandExecutorImpl(command); | ||
executor.addObserver(this); | ||
executor.execute(); | ||
} | ||
|
||
private void loadMenu() throws JAXBException { | ||
InputStream xml = InitialConfigurator.class.getClassLoader() | ||
.getResourceAsStream("menu.xml"); | ||
JAXBContext jaxbContext = JAXBContext.newInstance(Menu.class); | ||
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); | ||
Menu menu = (Menu)unmarshaller.unmarshal(xml); | ||
this.setMenu(menu); | ||
|
||
|
||
} | ||
|
||
@Override | ||
public void finishedCommand(Command cmd) { | ||
computeMap(cmd.getOutput().getScriptHelp()); | ||
} | ||
|
||
private void computeMap(ScriptHelp scriptHelp){ | ||
if (scriptHelp!=null){ | ||
for (Script script : scriptHelp.getScripts()){ | ||
for (String category : script.getCategories()){ | ||
if (!scriptCategories.containsKey(category)) | ||
scriptCategories.put(category,new ArrayList<Script>()); | ||
scriptCategories.get(category).add(script); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/java/com/uniovi/nmapgui/model/ExecutionObjectFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.uniovi.nmapgui.model; | ||
|
||
import javax.xml.bind.annotation.XmlRegistry; | ||
|
||
@XmlRegistry | ||
public class ExecutionObjectFactory { | ||
|
||
public Scan createScan() { | ||
return new Scan(); | ||
} | ||
|
||
public ScriptHelp createScriptHelp() { | ||
return new ScriptHelp(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.uniovi.nmapgui.model; | ||
|
||
import java.util.List; | ||
|
||
import javax.xml.bind.annotation.XmlAttribute; | ||
import javax.xml.bind.annotation.XmlElement; | ||
import javax.xml.bind.annotation.XmlElementWrapper; | ||
|
||
public class Script { | ||
private List<String> categories; | ||
private String description; | ||
private String filename; | ||
private String name; | ||
|
||
public String getName() { | ||
if (name!=null) | ||
return name; | ||
String[] split = filename.split("/"); | ||
return name=split[split.length-1].replace(".nse", ""); | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
@XmlElementWrapper(name="categories", required=false) | ||
@XmlElement(name="category", required=false) | ||
public List<String> getCategories() { | ||
return categories; | ||
} | ||
|
||
public void setCategories(List<String> categories) { | ||
this.categories = categories; | ||
} | ||
|
||
@XmlElement(name="description") | ||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
@XmlAttribute(name="filename") | ||
public String getFilename() { | ||
return filename; | ||
} | ||
|
||
public void setFilename(String filename) { | ||
this.filename = filename; | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.uniovi.nmapgui.model; | ||
|
||
import java.util.List; | ||
|
||
import javax.xml.bind.annotation.XmlElement; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
|
||
@XmlRootElement(name = "nse-scripts") | ||
public class ScriptHelp { | ||
|
||
private List<Script> scripts; | ||
|
||
@XmlElement(name="script") | ||
public List<Script> getScripts() { | ||
return scripts; | ||
} | ||
|
||
public void setScripts(List<Script> scripts) { | ||
this.scripts = scripts; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Scripts [" + getScripts() + "]"; | ||
} | ||
} |
Oops, something went wrong.