Skip to content
This repository has been archived by the owner on May 30, 2020. It is now read-only.

Commit

Permalink
Latest stable barely working app.
Browse files Browse the repository at this point in the history
  • Loading branch information
NanoDano committed Apr 2, 2019
1 parent 3c2e33b commit 0ceab57
Show file tree
Hide file tree
Showing 25 changed files with 55 additions and 40 deletions.
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions app/README.rst → README.rst
Expand Up @@ -12,3 +12,13 @@ Source code
-----------

https://github.com/DevDungeon/AndroidPortScanner.git


To do
-----
- Change 3rd tab title to 'Settings'
- When 3rd tab is pressed, load settings layout fragment
- In the 3rd tab, have editable settings
- The ip/range to scan
- The list of ports to scan

Binary file added app/src/main/ic_launcher-web.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -6,39 +6,39 @@ import android.support.v7.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.activity_main.view.*
import java.util.concurrent.Executors
import java.util.concurrent.ThreadPoolExecutor


class MainActivity : AppCompatActivity() {

private val numThreads: Int = 16
private val host: String = "www.devdungeon.com"

private val mOnNavigationItemSelectedListener = BottomNavigationView.OnNavigationItemSelectedListener { item ->
when (item.itemId) {
R.id.navigation_home -> {
return@OnNavigationItemSelectedListener true
}
R.id.navigation_dashboard -> {
this.scrollView2.portScanResults.setText("")
R.id.navigation_startscan -> {
this.scrollView2.portScanResults.setText("Scan results for:\n$host\n============")

val executor = Executors.newFixedThreadPool(10)
val executor = Executors.newFixedThreadPool(numThreads)

val commonlyUsedPorts = intArrayOf(22, 80, 443, 3306, 21, 25, 53, 8080, 8988, 9999)
for (port in commonlyUsedPorts) {
val worker = PortScan(this.scrollView2.portScanResults, port)
//val worker = Thread(PortScan(this.scrollView2.portScanResults, host, port))
val worker = PortScan(this.scrollView2.portScanResults, host, port)
executor.execute(worker)
}

executor.shutdown()
while (!executor.isTerminated()) {
// Threads are still running
}

// while (!executor.isTerminated()) { // This will lock up UI thread
// // Threads are still running
// }


return@OnNavigationItemSelectedListener true
return@OnNavigationItemSelectedListener false
}
R.id.navigation_notifications -> {
R.id.navigation_settings -> {
// Replace screen fragment with settings
return@OnNavigationItemSelectedListener true
}
}
Expand Down
24 changes: 12 additions & 12 deletions app/src/main/java/com/devdungeon/android/portscanner/PortScan.kt
Expand Up @@ -3,11 +3,11 @@ package com.devdungeon.android.portscanner
import android.widget.EditText
import java.net.Socket

class PortScan(val results: EditText, val portNumber: Int) : Thread() {
class PortScan(val results: EditText, val host: String, val portNumber: Int) : Thread() {

override fun run() {
try {
val sock = Socket("www.devdungeon.com", portNumber)
val sock = Socket(host, portNumber)
if (sock.isConnected) {
results.post(Runnable() {
val newMessage = "${results.text}" + "\n" +
Expand All @@ -16,19 +16,19 @@ class PortScan(val results: EditText, val portNumber: Int) : Thread() {
})
sock.close()
} else {
// results.post(Runnable() {
// val newMessage = "${results.text}" + "\n" +
// "$portNumber is not connected."
// results.setText(newMessage)
// })
results.post(Runnable() {
val newMessage = "${results.text}" + "\n" +
"$portNumber is not connected."
results.setText(newMessage)
})
}

} catch (e: Exception) {
// results.post(Runnable() {
// val newMessage = "${results.text}" + "\n" +
// "$portNumber is N/A."
// results.setText(newMessage)
// })
results.post(Runnable() {
val newMessage = "${results.text}" + "\n" +
"$portNumber is N/A."
results.setText(newMessage)
})
}
}
}
10 changes: 5 additions & 5 deletions app/src/main/res/drawable/ic_launcher_background.xml
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:height="108dp"
android:width="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
android:height="108dp"
android:width="108dp"
android:viewportHeight="108"
android:viewportWidth="108"
xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#008577"
android:pathData="M0,0h108v108h-108z"/>
<path android:fillColor="#00000000" android:pathData="M9,0L9,108"
Expand Down
13 changes: 6 additions & 7 deletions app/src/main/res/menu/navigation.xml
Expand Up @@ -7,13 +7,12 @@
android:title="@string/title_home"/>

<item
android:id="@+id/navigation_dashboard"
android:icon="@drawable/ic_dashboard_black_24dp"
android:title="@string/title_dashboard"/>

android:id="@+id/navigation_startscan"
android:icon="@android:drawable/ic_media_play"
android:title="@string/title_startscan"/>
<item
android:id="@+id/navigation_notifications"
android:icon="@drawable/ic_notifications_black_24dp"
android:title="@string/title_notifications"/>
android:id="@+id/navigation_settings"
android:icon="@android:drawable/ic_menu_more"
android:title="@string/title_settings"/>

</menu>
2 changes: 1 addition & 1 deletion app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
2 changes: 1 addition & 1 deletion app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Binary file modified app/src/main/res/mipmap-hdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-mdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xhdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
@@ -1,6 +1,6 @@
<resources>
<string name="app_name">Port Scanner</string>
<string name="title_home">Port Scanner</string>
<string name="title_dashboard">Start scan</string>
<string name="title_notifications">Notifications</string>
<string name="title_startscan">Start scan</string>
<string name="title_settings">Settings</string>
</resources>

0 comments on commit 0ceab57

Please sign in to comment.