Skip to content

Commit

Permalink
2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DerGoogler authored Feb 29, 2024
1 parent 0a848f4 commit 9a3e7d2
Show file tree
Hide file tree
Showing 9 changed files with 203 additions and 97 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: DerGoogler
29 changes: 29 additions & 0 deletions .github/workflows/module.yaml
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 }}
16 changes: 16 additions & 0 deletions README.md
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
4 changes: 2 additions & 2 deletions module.prop
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 system/usr/share/mmrl/config/mmrl_wpd/components/CenterBox.jsx
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 system/usr/share/mmrl/config/mmrl_wpd/components/RenderToolbar.jsx
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 system/usr/share/mmrl/config/mmrl_wpd/hooks/useConfigStore.js
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 system/usr/share/mmrl/config/mmrl_wpd/hooks/useNetworks.js
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;
};
150 changes: 55 additions & 95 deletions system/usr/share/mmrl/config/mmrl_wpd/index.jsx
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/.*>&quot;//;s/&quot;.*//;s/ /-_-/g"))
PSK=(\$(grep 'name="PreSharedKey"' \$config | sed "s/<null.*/NONE/;s/.*>&quot;//;s/&quot;.*//;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 />;
}
};

0 comments on commit 9a3e7d2

Please sign in to comment.