PDA

View Full Version : روت کردن با استفاده از کد



shahin bahari
چهارشنبه 13 دی 1391, 18:01 عصر
سلام.
دوستان یکم اطلاعات در مورد نحوه روت کردن گوشی میخواستم. منظورم به کمک کامپیوتر و این موارد نیست.
یه برنامه دیده بودم اگر اشتباه نکنم Z 4 root .این برنامه بعد از اجرا میتونست گوشی رو root/unroot کنه. البته این برنامه گوشی من رو ساپورت نمیکرد و امکان تستش رو نداشتم. به هر حال میخوام بدونم با استفاده از چه کدی(کلاسی) میشه این گونه تغییراتی رو روی گوشی داد؟
ممنون.

hamid_hr
چهارشنبه 13 دی 1391, 18:40 عصر
سلام
ببخشيد من منظورتون رو از روت كردن نفهميدم ميشه يكم توضسح بدين

shahin bahari
چهارشنبه 13 دی 1391, 21:48 عصر
شما تو حالت عادی به فایل های سیستمی مثل فولدر data که توی برنامه میتونید چیزی رو داخلش ذخیره کنید و یا دستکاری فرکانس کاری پردازنده(ماکزیمم و مینیمم)
و....... دسترسی ندارید. به عبارتی یه محافظی است که باعث میشه کسی نا خواسته دستکاری روی گوشی انجام بده. شما فرض کن یکی بیاد و دیالر گوشی رو پاک کنه..........
بعد از روت شدن شما اجازه دسترسی به همه چیز رو دارید اما با مسئولیت خودتون! مثل ویندوز که میتونید چند تا فایل رو از درایو C پاک کنید و بعد از اون ویندوز دیگه بالا نیاد.(تو حالت عادی شما اصلا فایل های سیستمی رو روی گوشی نمیبینید که بخواید پاک کنید....)
روت کردن گوشی های اندرویدی یه چیز تو مایه های jail break گوشی های iphone هست که محدودیت ها رو بر میداره.

endexample
شنبه 07 بهمن 1391, 21:49 عصر
وقت بخیر دوست من خودم تا الان نیاز نداشتم برای روت شدن اما ظاهرا در اندروید با کد نویسی با دستور
Runtime.getRuntime().exec("su");
باید بتونیم روت بشیم که اینو خودم تست نکردم اما ظاهرا باید جواب بده

endexample
شنبه 07 بهمن 1391, 21:55 عصر
اینم یه مثال در این باره که روت میشه و روت شدنش رو هم تست میکنه




Process p;
try {
// Preform su to get root privledges
p = Runtime.getRuntime().exec("su");

// Attempt to write a file to a root-only
DataOutputStream os = new DataOutputStream(p.getOutputStream());
os.writeBytes("echo \"Do I have root?\" >/system/sd/temporary.txt\n");

// Close the terminal
os.writeBytes("exit\n");
os.flush();
try {
p.waitFor();
if (p.exitValue() != 255) {
// TODO Code to run on success
toastMessage("root");
}
else {
// TODO Code to run on unsuccessful
toastMessage("not root");
}
} catch (InterruptedException e) {
// TODO Code to run in interrupted exception
toastMessage("not root");
}
} catch (IOException e) {
// TODO Code to run in input/output exception
toastMessage("not root");
}

Nevercom
یک شنبه 08 بهمن 1391, 06:07 صبح
کلاً در لینوکس برای اجرای کدی با دسترسی root، از sudo استفاده میکنیم.
که خب هربار هم پسورد رو ازمون درخواست میکنه، تو گوشی ها اگر بحثی بعنوان روت کردن مطرح هست، حدس من این هست که بخاطر اینه که مثلاً فایل باینری su موجود نیست یا به هر نحوی بهش دسترسی نداریم.
مثلاً فایل روت کردن گوشی خودم رو که بررسی کردم، چند فایل از جمله su رو به سیستم اضافه میکرد، حالا این میتونه به این خاطر باشه که فایل موجود نیست و یا نسخه ی تغییر یافته هست.

در این کد شما از su برای یک پروسه درخواست مجوز میکنید. تنها درصورتی اینکار امکانپذیره که فایل su موجود باشه.
این روت کردن نیست، این اجرا کردن کدها با دسترسی ریشه هست.

پس اگر دنبال راهی هستید که گوشی ها رو روت کنید و به برنامه ها اجازه بدید با مجوز ریشه اجرا بشن، اول باید بفهمید که چه چیزی مانع اجرا شدن برنامه ها با دسترسی ریشه میشه.

نقل از ویکی پدیا:


The process of rooting varies widely by device, but usually includes exploiting (http://en.wikipedia.org/wiki/Exploit_%28computer_security%29) a security weakness in the firmware of the device, and then copying the su (http://en.wikipedia.org/wiki/Su_%28Unix%29)binary (http://en.wikipedia.org/wiki/Executable) to a location in the current process's PATH (http://en.wikipedia.org/wiki/PATH_%28variable%29) (e.g. /system/xbin/su) and granting it executable permissions with the chmod (http://en.wikipedia.org/wiki/Chmod) command. A supervisor application like SuperUser or SuperSU can regulate and log elevated permission requests from other applications. Many guides, tutorials, and automatic processes exist for popular Android devices facilitating a fast and easy rooting process.
For example, shortly after the T-Mobile G1 (http://en.wikipedia.org/wiki/T-Mobile_G1) was released it was quickly discovered that anything typed using the keyboard was being interpreted as a command in a privileged (root) shell. Although Google quickly released a patch to fix this, a signed image of the old firmware leaked, which gave users the ability to downgrade and use the original exploit to gain root access. Once an exploit is discovered, a custom recovery image that skips the digital signature (http://en.wikipedia.org/wiki/Digital_signature) check of a firmware update package can be flashed. In turn, using the custom recovery, a modified firmware update can be installed that typically includes the utilities (for example the Superuser app) needed to run apps as root.
The Google-branded (http://en.wikipedia.org/wiki/Google_Nexus) Android phones, the Nexus One (http://en.wikipedia.org/wiki/Nexus_One), Nexus S (http://en.wikipedia.org/wiki/Nexus_S), Galaxy Nexus (http://en.wikipedia.org/wiki/Galaxy_Nexus) and Nexus 4 (http://en.wikipedia.org/wiki/Nexus_4), as well as their tablet counter parts, the Nexus 7 (http://en.wikipedia.org/wiki/Nexus_7) and Nexus 10 (http://en.wikipedia.org/wiki/Nexus_10), can be boot-loader unlocked by simply connecting the device to a computer while in boot-loader mode and running the Fastboot (http://en.wikipedia.org/wiki/Fastboot) program with the command "fastboot oem unlock".[8] (http://en.wikipedia.org/wiki/Android_rooting#cite_note-8) After accepting a warning the boot-loader will be unlocked so that a new system image can be written directly to flash without the need for an exploit.
Recently, Motorola (http://en.wikipedia.org/wiki/Motorola), LG Electronics (http://en.wikipedia.org/wiki/LG_Electronics) and HTC Corporation (http://en.wikipedia.org/wiki/HTC_Corporation) have added security features to their devices at the hardware level in an attempt to prevent retail Android devices from being rooted.[citation needed (http://en.wikipedia.org/wiki/Wikipedia:Citation_needed)] For instance, the Motorola Droid X (http://en.wikipedia.org/wiki/Motorola_Droid_X) has a security boot-loader that will put the phone in "recovery mode" if unsigned firmware is loaded onto the device, and the Samsung Galaxy S II (http://en.wikipedia.org/wiki/Samsung_Galaxy_S_II) will display a yellow triangle indicator if the device firmware has been modified.