-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
0a848f4
commit 9a3e7d2
Showing
9 changed files
with
203 additions
and
97 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
github: DerGoogler |
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,29 @@ | ||
name: Build Magisk/KernelSU Module | ||
|
||
on: | ||
push: | ||
tags: [ v*.*.* ] | ||
|
||
jobs: | ||
build: | ||
name: Build Module | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup Apt Dependencies | ||
run: | | ||
sudo apt update -y && sudo apt upgrade -y | ||
sudo apt install zip unzip -y | ||
- name: Make | ||
shell: bash | ||
run: | | ||
zip -r "module.zip" * -x ".git" -x "README.md" | ||
- name: Publish | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: 'module.zip' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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,16 @@ | ||
# WiFi Password Viewer for MMRL | ||
|
||
An inspired project from [veez21](https://github.com/veez21)'s [wpd gist](https://gist.github.com/veez21/4f2541d271809864411e3ffbbe8e3df9), ported to MMRL. | ||
This project is also a example to show how powerful MMRL's ModConf feature is. | ||
|
||
Using `DOMParser` to extract local saved wifi passwords | ||
|
||
> [!IMPORTANT] | ||
> This project requires MMRL above 2.14.10! | ||
```js | ||
const wifiXmlParser = new DOMParser(); | ||
``` | ||
|
||
> This module does not extract passwords from unauthorized wifi's | ||
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,6 +1,6 @@ | ||
id=mmrl_wpd | ||
name=WiFi Password Viewer for MMRL | ||
version=1.1.0 | ||
versionCode=110 | ||
version=2.1.0 | ||
versionCde=210 | ||
author=Der_Googler, veez21 @ xda-developers | ||
description=View all your WiFi passwords inside MMRL |
19 changes: 19 additions & 0 deletions
19
system/usr/share/mmrl/config/mmrl_wpd/components/CenterBox.jsx
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,19 @@ | ||
import React from "react"; | ||
import { Box } from "@mui/material"; | ||
|
||
export default (props) => { | ||
return ( | ||
<Box | ||
component="h4" | ||
sx={{ | ||
position: "absolute", | ||
left: "50%", | ||
top: "calc(50% - 56px)", | ||
textAlign: "center", | ||
WebkitTransform: "translate(-50%, -50%)", | ||
transform: "translate(-50%, -50%)", | ||
}} | ||
children={props.children} | ||
/> | ||
); | ||
}; |
21 changes: 21 additions & 0 deletions
21
system/usr/share/mmrl/config/mmrl_wpd/components/RenderToolbar.jsx
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,21 @@ | ||
import React from "react"; | ||
import { Toolbar } from "@mmrl/ui"; | ||
import { useActivity } from "@mmrl/hooks"; | ||
|
||
export default () => { | ||
const { context } = useActivity(); | ||
return ( | ||
<Toolbar | ||
modifier="noshadow" | ||
sx={{ | ||
background: "rgb(188,2,194)", | ||
background: "linear-gradient(22deg, rgba(188,2,194,1) 0%, rgba(74,20,140,1) 100%)", | ||
}} | ||
> | ||
<Toolbar.Left> | ||
<Toolbar.BackButton onClick={context.popPage} /> | ||
</Toolbar.Left> | ||
<Toolbar.Center>WiFi Password Viewer</Toolbar.Center> | ||
</Toolbar> | ||
); | ||
}; |
20 changes: 20 additions & 0 deletions
20
system/usr/share/mmrl/config/mmrl_wpd/hooks/useConfigStore.js
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,20 @@ | ||
import React from "react"; | ||
|
||
export default () => { | ||
const [store, setStore] = React.useState(null); | ||
|
||
React.useEffect(() => { | ||
const miscWifiConfigStore = new SuFile("/data/misc/wifi/WifiConfigStore.xml"); | ||
const miscApexDataWifiConfigStore = new SuFile("/data/misc/apexdata/com.android.wifi/WifiConfigStore.xml"); | ||
|
||
if (miscWifiConfigStore.exist()) { | ||
setStore(miscWifiConfigStore.read()); | ||
} else if (miscApexDataWifiConfigStore.exist()) { | ||
setStore(miscApexDataWifiConfigStore.read()); | ||
} else { | ||
setStore(null); | ||
} | ||
}, []); | ||
|
||
return store; | ||
}; |
40 changes: 40 additions & 0 deletions
40
system/usr/share/mmrl/config/mmrl_wpd/hooks/useNetworks.js
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,40 @@ | ||
import React from "react"; | ||
|
||
const useConfigStore = include("hooks/useConfigStore.js") | ||
|
||
export default () => { | ||
const [networks, setNetworks] = React.useState(null); | ||
const config = useConfigStore(); | ||
|
||
React.useEffect(() => { | ||
if (config) { | ||
const wifiXmlParser = new DOMParser(); | ||
const xml = wifiXmlParser.parseFromString(config, "text/xml"); | ||
|
||
const WifiConfigStoreData = xml.getElementsByTagName("WifiConfigStoreData")[0]; | ||
const NetworkList = WifiConfigStoreData.getElementsByTagName("NetworkList")[0]; | ||
|
||
// array | ||
const Network = [...NetworkList.getElementsByTagName("Network")]; | ||
|
||
setNetworks( | ||
Network.flatMap((el) => { | ||
const WifiConfiguration = [...el.getElementsByTagName("WifiConfiguration")]; | ||
|
||
return WifiConfiguration.map((s) => { | ||
const ssid = s.querySelector('string[name="SSID"]').innerHTML; | ||
|
||
const psk = s.querySelector('string[name="PreSharedKey"]'); | ||
|
||
return { | ||
ssid: ssid.replace(/"(.+)"/g, "$1"), | ||
psk: psk ? psk.innerHTML.replace(/"(.+)"/g, "$1") : null, | ||
}; | ||
}); | ||
}) | ||
); | ||
} | ||
}, [config]); | ||
|
||
return networks; | ||
}; |
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,104 +1,64 @@ | ||
import React from "react"; | ||
import { Page, Toolbar } from "@mmrl/ui"; | ||
import { useActivity, useNativeStorage } from "@mmrl/hooks"; | ||
import { | ||
List, | ||
ListItem, | ||
ListItemText, | ||
Divider | ||
} from "@mui/material"; | ||
import Terminal from "@mmrl/terminal"; | ||
import { Page } from "@mmrl/ui"; | ||
import { useNativeStorage } from "@mmrl/hooks"; | ||
import { List, ListItem, ListItemText, Divider } from "@mui/material"; | ||
|
||
const __wpd = `[ "\$(whoami)" != "root" ] && { echo "root required"; exit 1; } | ||
configs=( /data/misc/wifi/WifiConfigStore.xml /data/misc/apexdata/com.android.wifi/WifiConfigStore.xml ) | ||
for z in \${configs[@]}; do | ||
if [ -f \$z ]; then | ||
config=\$z | ||
break | ||
fi | ||
done | ||
SSID=(\$(grep 'name="SSID"' \$config | sed "s/.*>"//;s/".*//;s/ /-_-/g")) | ||
PSK=(\$(grep 'name="PreSharedKey"' \$config | sed "s/<null.*/NONE/;s/.*>"//;s/".*//;s/ /-_-/g")) | ||
for i in \${!SSID[@]}; do | ||
echo "\${SSID[\$i]},\"\${PSK[\$i]}\"" | sed "s/-_-/ /g" | ||
done` | ||
const RenderToolbar = include("components/RenderToolbar.jsx"); | ||
const CenterBox = include("components/CenterBox.jsx"); | ||
const useNetworks = include("hooks/useNetworks.js"); | ||
|
||
function App() { | ||
const networks = useNetworks(); | ||
const [hidePasswords, setHidePasswords] = useNativeStorage("wpd_hide_passwords", true); | ||
|
||
function RenderToolbar() { | ||
const { context } = useActivity() | ||
if (!networks) { | ||
return ( | ||
<Toolbar modifier="noshadow" sx={{ | ||
background: "rgb(188,2,194)", | ||
background: "linear-gradient(22deg, rgba(188,2,194,1) 0%, rgba(74,20,140,1) 100%)" | ||
}}> | ||
<Toolbar.Left> | ||
<Toolbar.BackButton onClick={context.popPage} /> | ||
</Toolbar.Left> | ||
<Toolbar.Center> | ||
WiFi Password Viewer | ||
</Toolbar.Center> | ||
</Toolbar> | ||
) | ||
} | ||
|
||
function Wpd() { | ||
const [lines, setLines] = React.useState([]); | ||
const [hidePasswords, setHidePasswords] = useNativeStorage("wpd_hide_passwords", true) | ||
|
||
const addLine = (line) => { | ||
setLines((lines) => [...lines, line]); | ||
}; | ||
|
||
const saveLog = () => { | ||
write("/data/adb/wpd.log", lines.join("\n")) | ||
} | ||
|
||
const startLog = React.useMemo(() => { | ||
const envp = { | ||
MMRL_VER_NAME: BuildConfig.VERSION_NAME, | ||
PACKAGENAME: BuildConfig.APPLICATION_ID, | ||
}; | ||
<Page renderToolbar={RenderToolbar}> | ||
<CenterBox>No networks found</CenterBox> | ||
</Page> | ||
); | ||
} | ||
|
||
Terminal.exec({ | ||
command: __wpd, | ||
env: envp, | ||
onLine: (line) => { | ||
line = line.split(",") | ||
addLine({ | ||
ssid: line[0], | ||
psk: line[1] | ||
}); | ||
}, | ||
onExit: (code) => { }, | ||
}); | ||
}, []); | ||
return ( | ||
<Page renderToolbar={RenderToolbar} modifier="noshadow"> | ||
<List subheader={<ListSubheader>Settings</ListSubheader>}> | ||
<ListItem> | ||
<ListItemText primary="Hide passwords" /> | ||
<Switch checked={hidePasswords} onChange={(e) => setHidePasswords(e.target.checked)} /> | ||
</ListItem> | ||
</List> | ||
<Divider /> | ||
<List subheader={<ListSubheader>Passwords</ListSubheader>}> | ||
{networks.map((wifi) => ( | ||
<ListItem> | ||
<ListItemText | ||
sx={{ | ||
"& .MuiListItemText-secondary": { | ||
WebkitTextSecurity: wifi.psk !== null && hidePasswords ? "disc" : "none", | ||
wordWrap: "break-word", | ||
fontStyle: wifi.psk === null ? "italic" : "none", | ||
}, | ||
}} | ||
primary={wifi.ssid} | ||
secondary={wifi.psk ? wifi.psk : "Has no password"} | ||
/> | ||
</ListItem> | ||
))} | ||
</List> | ||
</Page> | ||
); | ||
} | ||
|
||
export default () => { | ||
if (BuildConfig.VERSION_CODE < 21410) { | ||
return ( | ||
<Page | ||
onShow={startLog} | ||
renderToolbar={RenderToolbar} | ||
modifier="noshadow"> | ||
<List subheader={<ListSubheader>Settings</ListSubheader>}> | ||
<ListItem> | ||
<ListItemText primary="Hide passwords" /> | ||
<Switch checked={hidePasswords} onChange={(e) => setHidePasswords(e.target.checked)} /> | ||
</ListItem> | ||
</List> | ||
<Divider /> | ||
<List subheader={<ListSubheader>Passwords</ListSubheader>}> | ||
{lines.map((line) => ( | ||
<ListItem> | ||
<ListItemText sx={{ | ||
"& .MuiListItemText-secondary": { | ||
WebkitTextSecurity: hidePasswords ? "disc" : "none", | ||
wordWrap: "break-word" | ||
} | ||
}} primary={line.ssid} secondary={line.psk} /> | ||
</ListItem> | ||
))} | ||
</List> | ||
</Page> | ||
<Page renderToolbar={RenderToolbar}> | ||
<CenterBox> | ||
WPD requires MMRL above <strong>2.14.10</strong>! | ||
</CenterBox> | ||
</Page> | ||
); | ||
} | ||
|
||
export default Wpd | ||
} else { | ||
return <App />; | ||
} | ||
}; |