需要root权限才可以获取
#include <stdio.h>
#include <string.h>
#include <conio.h>
void left(char *czf, char *yzf, int n) {
char *a = czf, *b = yzf;
while (n--)
*(a++) = *(b++);
*(a++) = '\0';
}
void main() {
FILE *fp;
char *zc, zc2[10240], *zc3, zc4[1024];
system("su -c 'chmod 777 /data/misc/wifi/wpa_supplicant.conf'");
clrscr();
zc = zc2;
fp = fopen("/data/misc/wifi/wpa_supplicant.conf", "r");
if (fp == NULL) {
printf("无Root权限!");
} else {
while (!feof(fp)) {
*zc = fgetc(fp);
zc++;
}
fclose(fp);
system("su -c 'chmod 660 /data/misc/wifi/wpa_supplicant.conf'");
clrscr();
zc3 = strtok(zc2, "=");
while ((zc3 = strtok(NULL, "="))) {
if (strstr(zc3, "\"") != 0) {
if (strstr(zc3, "psk") != 0) {
left(zc4, ++zc3, strlen(zc3) - 6);
printf("\n账号:");
} else {
if (strstr(zc3, "key") == 0) {
left(zc4, ++zc3, strlen(zc3) - 12);
printf("\n账号:");
} else {
left(zc4, ++zc3, strlen(zc3) - 11);
printf("密码:");
}
}
printf("%s\n", zc4);
}
}
}
}
#include <stdio.h>
#include <string.h>
#include <conio.h>
void left(char *czf, char *yzf, int n) {
char *a = czf, *b = yzf;
while (n--)
*(a++) = *(b++);
*(a++) = '\0';
}
void main() {
FILE *fp;
char *zc, zc2[10240], *zc3, zc4[1024];
system("su -c 'chmod 777 /data/misc/wifi/wpa_supplicant.conf'");
clrscr();
zc = zc2;
fp = fopen("/data/misc/wifi/wpa_supplicant.conf", "r");
if (fp == NULL) {
printf("无Root权限!");
} else {
while (!feof(fp)) {
*zc = fgetc(fp);
zc++;
}
fclose(fp);
system("su -c 'chmod 660 /data/misc/wifi/wpa_supplicant.conf'");
clrscr();
zc3 = strtok(zc2, "=");
while ((zc3 = strtok(NULL, "="))) {
if (strstr(zc3, "\"") != 0) {
if (strstr(zc3, "psk") != 0) {
left(zc4, ++zc3, strlen(zc3) - 6);
printf("\n账号:");
} else {
if (strstr(zc3, "key") == 0) {
left(zc4, ++zc3, strlen(zc3) - 12);
printf("\n账号:");
} else {
left(zc4, ++zc3, strlen(zc3) - 11);
printf("密码:");
}
}
printf("%s\n", zc4);
}
}
}
}