/usr/bin/rkhunter is in rkhunter 1.4.2-0.4+deb8u1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 11987 11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 12427 12428 12429 12430 12431 12432 12433 12434 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 12488 12489 12490 12491 12492 12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 12603 12604 12605 12606 12607 12608 12609 12610 12611 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 12637 12638 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 12680 12681 12682 12683 12684 12685 12686 12687 12688 12689 12690 12691 12692 12693 12694 12695 12696 12697 12698 12699 12700 12701 12702 12703 12704 12705 12706 12707 12708 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 12719 12720 12721 12722 12723 12724 12725 12726 12727 12728 12729 12730 12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 12781 12782 12783 12784 12785 12786 12787 12788 12789 12790 12791 12792 12793 12794 12795 12796 12797 12798 12799 12800 12801 12802 12803 12804 12805 12806 12807 12808 12809 12810 12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 12933 12934 12935 12936 12937 12938 12939 12940 12941 12942 12943 12944 12945 12946 12947 12948 12949 12950 12951 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250 13251 13252 13253 13254 13255 13256 13257 13258 13259 13260 13261 13262 13263 13264 13265 13266 13267 13268 13269 13270 13271 13272 13273 13274 13275 13276 13277 13278 13279 13280 13281 13282 13283 13284 13285 13286 13287 13288 13289 13290 13291 13292 13293 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 13330 13331 13332 13333 13334 13335 13336 13337 13338 13339 13340 13341 13342 13343 13344 13345 13346 13347 13348 13349 13350 13351 13352 13353 13354 13355 13356 13357 13358 13359 13360 13361 13362 13363 13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 13378 13379 13380 13381 13382 13383 13384 13385 13386 13387 13388 13389 13390 13391 13392 13393 13394 13395 13396 13397 13398 13399 13400 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 13414 13415 13416 13417 13418 13419 13420 13421 13422 13423 13424 13425 13426 13427 13428 13429 13430 13431 13432 13433 13434 13435 13436 13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 13465 13466 13467 13468 13469 13470 13471 13472 13473 13474 13475 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 13486 13487 13488 13489 13490 13491 13492 13493 13494 13495 13496 13497 13498 13499 13500 13501 13502 13503 13504 13505 13506 13507 13508 13509 13510 13511 13512 13513 13514 13515 13516 13517 13518 13519 13520 13521 13522 13523 13524 13525 13526 13527 13528 13529 13530 13531 13532 13533 13534 13535 13536 13537 13538 13539 13540 13541 13542 13543 13544 13545 13546 13547 13548 13549 13550 13551 13552 13553 13554 13555 13556 13557 13558 13559 13560 13561 13562 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 13581 13582 13583 13584 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 13601 13602 13603 13604 13605 13606 13607 13608 13609 13610 13611 13612 13613 13614 13615 13616 13617 13618 13619 13620 13621 13622 13623 13624 13625 13626 13627 13628 13629 13630 13631 13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 13642 13643 13644 13645 13646 13647 13648 13649 13650 13651 13652 13653 13654 13655 13656 13657 13658 13659 13660 13661 13662 13663 13664 13665 13666 13667 13668 13669 13670 13671 13672 13673 13674 13675 13676 13677 13678 13679 13680 13681 13682 13683 13684 13685 13686 13687 13688 13689 13690 13691 13692 13693 13694 13695 13696 13697 13698 13699 13700 13701 13702 13703 13704 13705 13706 13707 13708 13709 13710 13711 13712 13713 13714 13715 13716 13717 13718 13719 13720 13721 13722 13723 13724 13725 13726 13727 13728 13729 13730 13731 13732 13733 13734 13735 13736 13737 13738 13739 13740 13741 13742 13743 13744 13745 13746 13747 13748 13749 13750 13751 13752 13753 13754 13755 13756 13757 13758 13759 13760 13761 13762 13763 13764 13765 13766 13767 13768 13769 13770 13771 13772 13773 13774 13775 13776 13777 13778 13779 13780 13781 13782 13783 13784 13785 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 13799 13800 13801 13802 13803 13804 13805 13806 13807 13808 13809 13810 13811 13812 13813 13814 13815 13816 13817 13818 13819 13820 13821 13822 13823 13824 13825 13826 13827 13828 13829 13830 13831 13832 13833 13834 13835 13836 13837 13838 13839 13840 13841 13842 13843 13844 13845 13846 13847 13848 13849 13850 13851 13852 13853 13854 13855 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 13871 13872 13873 13874 13875 13876 13877 13878 13879 13880 13881 13882 13883 13884 13885 13886 13887 13888 13889 13890 13891 13892 13893 13894 13895 13896 13897 13898 13899 13900 13901 13902 13903 13904 13905 13906 13907 13908 13909 13910 13911 13912 13913 13914 13915 13916 13917 13918 13919 13920 13921 13922 13923 13924 13925 13926 13927 13928 13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 13944 13945 13946 13947 13948 13949 13950 13951 13952 13953 13954 13955 13956 13957 13958 13959 13960 13961 13962 13963 13964 13965 13966 13967 13968 13969 13970 13971 13972 13973 13974 13975 13976 13977 13978 13979 13980 13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 13998 13999 14000 14001 14002 14003 14004 14005 14006 14007 14008 14009 14010 14011 14012 14013 14014 14015 14016 14017 14018 14019 14020 14021 14022 14023 14024 14025 14026 14027 14028 14029 14030 14031 14032 14033 14034 14035 14036 14037 14038 14039 14040 14041 14042 14043 14044 14045 14046 14047 14048 14049 14050 14051 14052 14053 14054 14055 14056 14057 14058 14059 14060 14061 14062 14063 14064 14065 14066 14067 14068 14069 14070 14071 14072 14073 14074 14075 14076 14077 14078 14079 14080 14081 14082 14083 14084 14085 14086 14087 14088 14089 14090 14091 14092 14093 14094 14095 14096 14097 14098 14099 14100 14101 14102 14103 14104 14105 14106 14107 14108 14109 14110 14111 14112 14113 14114 14115 14116 14117 14118 14119 14120 14121 14122 14123 14124 14125 14126 14127 14128 14129 14130 14131 14132 14133 14134 14135 14136 14137 14138 14139 14140 14141 14142 14143 14144 14145 14146 14147 14148 14149 14150 14151 14152 14153 14154 14155 14156 14157 14158 14159 14160 14161 14162 14163 14164 14165 14166 14167 14168 14169 14170 14171 14172 14173 14174 14175 14176 14177 14178 14179 14180 14181 14182 14183 14184 14185 14186 14187 14188 14189 14190 14191 14192 14193 14194 14195 14196 14197 14198 14199 14200 14201 14202 14203 14204 14205 14206 14207 14208 14209 14210 14211 14212 14213 14214 14215 14216 14217 14218 14219 14220 14221 14222 14223 14224 14225 14226 14227 14228 14229 14230 14231 14232 14233 14234 14235 14236 14237 14238 14239 14240 14241 14242 14243 14244 14245 14246 14247 14248 14249 14250 14251 14252 14253 14254 14255 14256 14257 14258 14259 14260 14261 14262 14263 14264 14265 14266 14267 14268 14269 14270 14271 14272 14273 14274 14275 14276 14277 14278 14279 14280 14281 14282 14283 14284 14285 14286 14287 14288 14289 14290 14291 14292 14293 14294 14295 14296 14297 14298 14299 14300 14301 14302 14303 14304 14305 14306 14307 14308 14309 14310 14311 14312 14313 14314 14315 14316 14317 14318 14319 14320 14321 14322 14323 14324 14325 14326 14327 14328 14329 14330 14331 14332 14333 14334 14335 14336 14337 14338 14339 14340 14341 14342 14343 14344 14345 14346 14347 14348 14349 14350 14351 14352 14353 14354 14355 14356 14357 14358 14359 14360 14361 14362 14363 14364 14365 14366 14367 14368 14369 14370 14371 14372 14373 14374 14375 14376 14377 14378 14379 14380 14381 14382 14383 14384 14385 14386 14387 14388 14389 14390 14391 14392 14393 14394 14395 14396 14397 14398 14399 14400 14401 14402 14403 14404 14405 14406 14407 14408 14409 14410 14411 14412 14413 14414 14415 14416 14417 14418 14419 14420 14421 14422 14423 14424 14425 14426 14427 14428 14429 14430 14431 14432 14433 14434 14435 14436 14437 14438 14439 14440 14441 14442 14443 14444 14445 14446 14447 14448 14449 14450 14451 14452 14453 14454 14455 14456 14457 14458 14459 14460 14461 14462 14463 14464 14465 14466 14467 14468 14469 14470 14471 14472 14473 14474 14475 14476 14477 14478 14479 14480 14481 14482 14483 14484 14485 14486 14487 14488 14489 14490 14491 14492 14493 14494 14495 14496 14497 14498 14499 14500 14501 14502 14503 14504 14505 14506 14507 14508 14509 14510 14511 14512 14513 14514 14515 14516 14517 14518 14519 14520 14521 14522 14523 14524 14525 14526 14527 14528 14529 14530 14531 14532 14533 14534 14535 14536 14537 14538 14539 14540 14541 14542 14543 14544 14545 14546 14547 14548 14549 14550 14551 14552 14553 14554 14555 14556 14557 14558 14559 14560 14561 14562 14563 14564 14565 14566 14567 14568 14569 14570 14571 14572 14573 14574 14575 14576 14577 14578 14579 14580 14581 14582 14583 14584 14585 14586 14587 14588 14589 14590 14591 14592 14593 14594 14595 14596 14597 14598 14599 14600 14601 14602 14603 14604 14605 14606 14607 14608 14609 14610 14611 14612 14613 14614 14615 14616 14617 14618 14619 14620 14621 14622 14623 14624 14625 14626 14627 14628 14629 14630 14631 14632 14633 14634 14635 14636 14637 14638 14639 14640 14641 14642 14643 14644 14645 14646 14647 14648 14649 14650 14651 14652 14653 14654 14655 14656 14657 14658 14659 14660 14661 14662 14663 14664 14665 14666 14667 14668 14669 14670 14671 14672 14673 14674 14675 14676 14677 14678 14679 14680 14681 14682 14683 14684 14685 14686 14687 14688 14689 14690 14691 14692 14693 14694 14695 14696 14697 14698 14699 14700 14701 14702 14703 14704 14705 14706 14707 14708 14709 14710 14711 14712 14713 14714 14715 14716 14717 14718 14719 14720 14721 14722 14723 14724 14725 14726 14727 14728 14729 14730 14731 14732 14733 14734 14735 14736 14737 14738 14739 14740 14741 14742 14743 14744 14745 14746 14747 14748 14749 14750 14751 14752 14753 14754 14755 14756 14757 14758 14759 14760 14761 14762 14763 14764 14765 14766 14767 14768 14769 14770 14771 14772 14773 14774 14775 14776 14777 14778 14779 14780 14781 14782 14783 14784 14785 14786 14787 14788 14789 14790 14791 14792 14793 14794 14795 14796 14797 14798 14799 14800 14801 14802 14803 14804 14805 14806 14807 14808 14809 14810 14811 14812 14813 14814 14815 14816 14817 14818 14819 14820 14821 14822 14823 14824 14825 14826 14827 14828 14829 14830 14831 14832 14833 14834 14835 14836 14837 14838 14839 14840 14841 14842 14843 14844 14845 14846 14847 14848 14849 14850 14851 14852 14853 14854 14855 14856 14857 14858 14859 14860 14861 14862 14863 14864 14865 14866 14867 14868 14869 14870 14871 14872 14873 14874 14875 14876 14877 14878 14879 14880 14881 14882 14883 14884 14885 14886 14887 14888 14889 14890 14891 14892 14893 14894 14895 14896 14897 14898 14899 14900 14901 14902 14903 14904 14905 14906 14907 14908 14909 14910 14911 14912 14913 14914 14915 14916 14917 14918 14919 14920 14921 14922 14923 14924 14925 14926 14927 14928 14929 14930 14931 14932 14933 14934 14935 14936 14937 14938 14939 14940 14941 14942 14943 14944 14945 14946 14947 14948 14949 14950 14951 14952 14953 14954 14955 14956 14957 14958 14959 14960 14961 14962 14963 14964 14965 14966 14967 14968 14969 14970 14971 14972 14973 14974 14975 14976 14977 14978 14979 14980 14981 14982 14983 14984 14985 14986 14987 14988 14989 14990 14991 14992 14993 14994 14995 14996 14997 14998 14999 15000 15001 15002 15003 15004 15005 15006 15007 15008 15009 15010 15011 15012 15013 15014 15015 15016 15017 15018 15019 15020 15021 15022 15023 15024 15025 15026 15027 15028 15029 15030 15031 15032 15033 15034 15035 15036 15037 15038 15039 15040 15041 15042 15043 15044 15045 15046 15047 15048 15049 15050 15051 15052 15053 15054 15055 15056 15057 15058 15059 15060 15061 15062 15063 15064 15065 15066 15067 15068 15069 15070 15071 15072 15073 15074 15075 15076 15077 15078 15079 15080 15081 15082 15083 15084 15085 15086 15087 15088 15089 15090 15091 15092 15093 15094 15095 15096 15097 15098 15099 15100 15101 15102 15103 15104 15105 15106 15107 15108 15109 15110 15111 15112 15113 15114 15115 15116 15117 15118 15119 15120 15121 15122 15123 15124 15125 15126 15127 15128 15129 15130 15131 15132 15133 15134 15135 15136 15137 15138 15139 15140 15141 15142 15143 15144 15145 15146 15147 15148 15149 15150 15151 15152 15153 15154 15155 15156 15157 15158 15159 15160 15161 15162 15163 15164 15165 15166 15167 15168 15169 15170 15171 15172 15173 15174 15175 15176 15177 15178 15179 15180 15181 15182 15183 15184 15185 15186 15187 15188 15189 15190 15191 15192 15193 15194 15195 15196 15197 15198 15199 15200 15201 15202 15203 15204 15205 15206 15207 15208 15209 15210 15211 15212 15213 15214 15215 15216 15217 15218 15219 15220 15221 15222 15223 15224 15225 15226 15227 15228 15229 15230 15231 15232 15233 15234 15235 15236 15237 15238 15239 15240 15241 15242 15243 15244 15245 15246 15247 15248 15249 15250 15251 15252 15253 15254 15255 15256 15257 15258 15259 15260 15261 15262 15263 15264 15265 15266 15267 15268 15269 15270 15271 15272 15273 15274 15275 15276 15277 15278 15279 15280 15281 15282 15283 15284 15285 15286 15287 15288 15289 15290 15291 15292 15293 15294 15295 15296 15297 15298 15299 15300 15301 15302 15303 15304 15305 15306 15307 15308 15309 15310 15311 15312 15313 15314 15315 15316 15317 15318 15319 15320 15321 15322 15323 15324 15325 15326 15327 15328 15329 15330 15331 15332 15333 15334 15335 15336 15337 15338 15339 15340 15341 15342 15343 15344 15345 15346 15347 15348 15349 15350 15351 15352 15353 15354 15355 15356 15357 15358 15359 15360 15361 15362 15363 15364 15365 15366 15367 15368 15369 15370 15371 15372 15373 15374 15375 15376 15377 15378 15379 15380 15381 15382 15383 15384 15385 15386 15387 15388 15389 15390 15391 15392 15393 15394 15395 15396 15397 15398 15399 15400 15401 15402 15403 15404 15405 15406 15407 15408 15409 15410 15411 15412 15413 15414 15415 15416 15417 15418 15419 15420 15421 15422 15423 15424 15425 15426 15427 15428 15429 15430 15431 15432 15433 15434 15435 15436 15437 15438 15439 15440 15441 15442 15443 15444 15445 15446 15447 15448 15449 15450 15451 15452 15453 15454 15455 15456 15457 15458 15459 15460 15461 15462 15463 15464 15465 15466 15467 15468 15469 15470 15471 15472 15473 15474 15475 15476 15477 15478 15479 15480 15481 15482 15483 15484 15485 15486 15487 15488 15489 15490 15491 15492 15493 15494 15495 15496 15497 15498 15499 15500 15501 15502 15503 15504 15505 15506 15507 15508 15509 15510 15511 15512 15513 15514 15515 15516 15517 15518 15519 15520 15521 15522 15523 15524 15525 15526 15527 15528 15529 15530 15531 15532 15533 15534 15535 15536 15537 15538 15539 15540 15541 15542 15543 15544 15545 15546 15547 15548 15549 15550 15551 15552 15553 15554 15555 15556 15557 15558 15559 15560 15561 15562 15563 15564 15565 15566 15567 15568 15569 15570 15571 15572 15573 15574 15575 15576 15577 15578 15579 15580 15581 15582 15583 15584 15585 15586 15587 15588 15589 15590 15591 15592 15593 15594 15595 15596 15597 15598 15599 15600 15601 15602 15603 15604 15605 15606 15607 15608 15609 15610 15611 15612 15613 15614 15615 15616 15617 15618 15619 15620 15621 15622 15623 15624 15625 15626 15627 15628 15629 15630 15631 15632 15633 15634 15635 15636 15637 15638 15639 15640 15641 15642 15643 15644 15645 15646 15647 15648 15649 15650 15651 15652 15653 15654 15655 15656 15657 15658 15659 15660 15661 15662 15663 15664 15665 15666 15667 15668 15669 15670 15671 15672 15673 15674 15675 15676 15677 15678 15679 15680 15681 15682 15683 15684 15685 15686 15687 15688 15689 15690 15691 15692 15693 15694 15695 15696 15697 15698 15699 15700 15701 15702 15703 15704 15705 15706 15707 15708 15709 15710 15711 15712 15713 15714 15715 15716 15717 15718 15719 15720 15721 15722 15723 15724 15725 15726 15727 15728 15729 15730 15731 15732 15733 15734 15735 15736 15737 15738 15739 15740 15741 15742 15743 15744 15745 15746 15747 15748 15749 15750 15751 15752 15753 15754 15755 15756 15757 15758 15759 15760 15761 15762 15763 15764 15765 15766 15767 15768 15769 15770 15771 15772 15773 15774 15775 15776 15777 15778 15779 15780 15781 15782 15783 15784 15785 15786 15787 15788 15789 15790 15791 15792 15793 15794 15795 15796 15797 15798 15799 15800 15801 15802 15803 15804 15805 15806 15807 15808 15809 15810 15811 15812 15813 15814 15815 15816 15817 15818 15819 15820 15821 15822 15823 15824 15825 15826 15827 15828 15829 15830 15831 15832 15833 15834 15835 15836 15837 15838 15839 15840 15841 15842 15843 15844 15845 15846 15847 15848 15849 15850 15851 15852 15853 15854 15855 15856 15857 15858 15859 15860 15861 15862 15863 15864 15865 15866 15867 15868 15869 15870 15871 15872 15873 15874 15875 15876 15877 15878 15879 15880 15881 15882 15883 15884 15885 15886 15887 15888 15889 15890 15891 15892 15893 15894 15895 15896 15897 15898 15899 15900 15901 15902 15903 15904 15905 15906 15907 15908 15909 15910 15911 15912 15913 15914 15915 15916 15917 15918 15919 15920 15921 15922 15923 15924 15925 15926 15927 15928 15929 15930 15931 15932 15933 15934 15935 15936 15937 15938 15939 15940 15941 15942 15943 15944 15945 15946 15947 15948 15949 15950 15951 15952 15953 15954 15955 15956 15957 15958 15959 15960 15961 15962 15963 15964 15965 15966 15967 15968 15969 15970 15971 15972 15973 15974 15975 15976 15977 15978 15979 15980 15981 15982 15983 15984 15985 15986 15987 15988 15989 15990 15991 15992 15993 15994 15995 15996 15997 15998 15999 16000 16001 16002 16003 16004 16005 16006 16007 16008 16009 16010 16011 16012 16013 16014 16015 16016 16017 16018 16019 16020 16021 16022 16023 16024 16025 16026 16027 16028 16029 16030 16031 16032 16033 16034 16035 16036 16037 16038 16039 16040 16041 16042 16043 16044 16045 16046 16047 16048 16049 16050 16051 16052 16053 16054 16055 16056 16057 16058 16059 16060 16061 16062 16063 16064 16065 16066 16067 16068 16069 16070 16071 16072 16073 16074 16075 16076 16077 16078 16079 16080 16081 16082 16083 16084 16085 16086 16087 16088 16089 16090 16091 16092 16093 16094 16095 16096 16097 16098 16099 16100 16101 16102 16103 16104 16105 16106 16107 16108 16109 16110 16111 16112 16113 16114 16115 16116 16117 16118 16119 16120 16121 16122 16123 16124 16125 16126 16127 16128 16129 16130 16131 16132 16133 16134 16135 16136 16137 16138 16139 16140 16141 16142 16143 16144 16145 16146 16147 16148 16149 16150 16151 16152 16153 16154 16155 16156 16157 16158 16159 16160 16161 16162 16163 16164 16165 16166 16167 16168 16169 16170 16171 16172 16173 16174 16175 16176 16177 16178 16179 16180 16181 16182 16183 16184 16185 16186 16187 16188 16189 16190 16191 16192 16193 16194 16195 16196 16197 16198 16199 16200 16201 16202 16203 16204 16205 16206 16207 16208 16209 16210 16211 16212 16213 16214 16215 16216 16217 16218 16219 16220 16221 16222 16223 16224 16225 16226 16227 16228 16229 16230 16231 16232 16233 16234 16235 16236 16237 16238 16239 16240 16241 16242 16243 16244 16245 16246 16247 16248 16249 16250 16251 16252 16253 16254 16255 16256 16257 16258 16259 16260 16261 16262 16263 16264 16265 16266 16267 16268 16269 16270 16271 16272 16273 16274 16275 16276 16277 16278 16279 16280 16281 16282 16283 16284 16285 16286 16287 16288 16289 16290 16291 16292 16293 16294 16295 16296 16297 16298 16299 16300 16301 16302 16303 16304 16305 16306 16307 16308 16309 16310 16311 16312 16313 16314 16315 16316 16317 16318 16319 16320 16321 16322 16323 16324 16325 16326 16327 16328 16329 16330 16331 16332 16333 16334 16335 16336 16337 16338 16339 16340 16341 16342 16343 16344 16345 16346 16347 16348 16349 16350 16351 16352 16353 16354 16355 16356 16357 16358 16359 16360 16361 16362 16363 16364 16365 16366 16367 16368 16369 16370 16371 16372 16373 16374 16375 16376 16377 16378 16379 16380 16381 16382 16383 16384 16385 16386 16387 16388 16389 16390 16391 16392 16393 16394 16395 16396 16397 16398 16399 16400 16401 16402 16403 16404 16405 16406 16407 16408 16409 16410 16411 16412 16413 16414 16415 16416 16417 16418 16419 16420 16421 16422 16423 16424 16425 16426 16427 16428 16429 16430 16431 16432 16433 16434 16435 16436 16437 16438 16439 16440 16441 16442 16443 16444 16445 16446 16447 16448 16449 16450 16451 16452 16453 16454 16455 16456 16457 16458 16459 16460 16461 16462 16463 16464 16465 16466 16467 16468 16469 16470 16471 16472 16473 16474 16475 16476 16477 16478 16479 16480 16481 16482 16483 16484 16485 16486 16487 16488 16489 16490 16491 16492 16493 16494 16495 16496 16497 16498 16499 16500 16501 16502 16503 16504 16505 16506 16507 16508 16509 16510 16511 16512 16513 16514 16515 16516 16517 16518 16519 16520 16521 16522 16523 16524 16525 16526 16527 16528 16529 16530 16531 16532 16533 16534 16535 16536 16537 16538 16539 16540 16541 16542 16543 16544 16545 16546 16547 16548 16549 16550 16551 16552 16553 16554 16555 16556 16557 16558 16559 16560 16561 16562 16563 16564 16565 16566 16567 16568 16569 16570 16571 16572 16573 16574 16575 16576 16577 16578 16579 16580 16581 16582 16583 16584 16585 16586 16587 16588 16589 16590 16591 16592 16593 16594 16595 16596 16597 16598 16599 16600 16601 16602 16603 16604 16605 16606 16607 16608 16609 16610 16611 16612 16613 16614 16615 16616 16617 16618 16619 16620 16621 16622 16623 16624 16625 16626 16627 16628 16629 16630 16631 16632 16633 16634 16635 16636 16637 16638 16639 16640 16641 16642 16643 16644 16645 16646 16647 16648 16649 16650 16651 16652 16653 16654 16655 16656 16657 16658 16659 16660 16661 16662 16663 16664 16665 16666 16667 16668 16669 16670 16671 16672 16673 16674 16675 16676 16677 16678 16679 16680 16681 16682 16683 16684 16685 16686 16687 16688 16689 16690 16691 16692 16693 16694 16695 16696 16697 16698 16699 16700 16701 16702 16703 16704 16705 16706 16707 16708 16709 16710 16711 16712 16713 16714 16715 16716 16717 16718 16719 16720 16721 16722 16723 16724 16725 16726 16727 16728 16729 16730 16731 16732 16733 16734 16735 16736 16737 16738 16739 16740 16741 16742 16743 16744 16745 16746 16747 16748 16749 16750 16751 16752 16753 16754 16755 16756 16757 16758 16759 16760 16761 16762 16763 16764 16765 16766 16767 16768 16769 16770 16771 16772 16773 16774 16775 16776 16777 16778 16779 16780 16781 16782 16783 16784 16785 16786 16787 16788 16789 16790 16791 16792 16793 16794 16795 16796 16797 16798 16799 16800 16801 16802 16803 16804 16805 16806 16807 16808 16809 16810 16811 16812 16813 16814 16815 16816 16817 16818 16819 16820 16821 16822 16823 16824 16825 16826 16827 16828 16829 16830 16831 16832 16833 16834 16835 16836 16837 16838 16839 16840 16841 16842 16843 16844 16845 16846 16847 16848 16849 16850 16851 16852 16853 16854 16855 16856 16857 16858 16859 16860 16861 16862 16863 16864 16865 16866 16867 16868 16869 16870 16871 16872 16873 16874 16875 16876 16877 16878 16879 16880 16881 16882 16883 16884 16885 16886 16887 16888 16889 16890 16891 16892 16893 16894 16895 16896 16897 16898 16899 16900 16901 16902 16903 16904 16905 16906 16907 16908 16909 16910 16911 16912 16913 16914 16915 16916 16917 16918 16919 16920 16921 16922 16923 16924 16925 16926 16927 16928 16929 16930 16931 16932 16933 16934 16935 16936 16937 16938 16939 16940 16941 16942 16943 16944 16945 16946 16947 16948 16949 16950 16951 16952 16953 16954 16955 16956 16957 16958 16959 16960 16961 16962 16963 16964 16965 16966 16967 16968 16969 16970 16971 16972 16973 16974 16975 16976 16977 16978 16979 16980 16981 16982 16983 16984 16985 16986 16987 16988 16989 16990 16991 16992 16993 16994 16995 16996 16997 16998 16999 17000 17001 17002 17003 17004 17005 17006 17007 17008 17009 17010 17011 17012 17013 17014 17015 17016 17017 17018 17019 17020 17021 17022 17023 17024 17025 17026 17027 17028 17029 17030 17031 17032 17033 17034 17035 17036 17037 17038 17039 17040 17041 17042 17043 17044 17045 17046 17047 17048 17049 17050 17051 17052 17053 17054 17055 17056 17057 17058 17059 17060 17061 17062 17063 17064 17065 17066 17067 17068 17069 17070 17071 17072 17073 17074 17075 17076 17077 17078 17079 17080 17081 17082 17083 17084 17085 17086 17087 17088 17089 17090 17091 17092 17093 17094 17095 17096 17097 17098 17099 17100 17101 17102 17103 17104 17105 17106 17107 17108 17109 17110 17111 17112 17113 17114 17115 17116 17117 17118 17119 17120 17121 17122 17123 17124 17125 17126 17127 17128 17129 17130 17131 17132 17133 17134 17135 17136 17137 17138 17139 17140 17141 17142 17143 17144 17145 17146 17147 17148 17149 17150 17151 17152 17153 17154 17155 17156 17157 17158 17159 17160 17161 17162 17163 17164 17165 17166 17167 17168 17169 17170 17171 17172 17173 17174 17175 17176 17177 17178 17179 17180 17181 17182 17183 17184 17185 17186 17187 17188 17189 17190 17191 17192 17193 17194 17195 17196 17197 17198 17199 17200 17201 17202 17203 17204 17205 17206 17207 17208 17209 17210 17211 17212 17213 17214 17215 17216 17217 17218 17219 17220 17221 17222 17223 17224 17225 17226 17227 17228 17229 17230 17231 17232 17233 17234 17235 17236 17237 17238 17239 17240 17241 17242 17243 17244 17245 17246 17247 17248 17249 17250 17251 17252 17253 17254 17255 17256 17257 17258 17259 17260 17261 17262 17263 17264 17265 17266 17267 17268 17269 17270 17271 17272 17273 17274 17275 17276 17277 17278 17279 17280 17281 17282 17283 17284 17285 17286 17287 17288 17289 17290 17291 17292 17293 17294 17295 17296 17297 17298 17299 17300 17301 17302 17303 17304 17305 17306 17307 17308 17309 17310 17311 17312 17313 17314 17315 17316 17317 17318 17319 17320 17321 17322 17323 17324 17325 17326 17327 17328 17329 17330 17331 17332 17333 17334 17335 17336 17337 17338 17339 17340 17341 17342 17343 17344 17345 17346 17347 17348 17349 17350 17351 17352 17353 17354 17355 17356 17357 17358 17359 17360 17361 17362 17363 17364 17365 17366 17367 17368 17369 17370 17371 17372 17373 17374 17375 17376 17377 17378 17379 17380 17381 17382 17383 17384 17385 17386 17387 17388 17389 17390 17391 17392 17393 17394 17395 17396 17397 17398 17399 17400 17401 17402 17403 17404 17405 17406 17407 17408 17409 17410 17411 17412 17413 17414 17415 17416 17417 17418 17419 17420 17421 17422 17423 17424 17425 17426 17427 17428 17429 17430 17431 17432 17433 17434 17435 17436 17437 17438 17439 17440 17441 17442 17443 17444 17445 17446 17447 17448 17449 17450 17451 17452 17453 17454 17455 17456 17457 17458 17459 17460 17461 17462 17463 17464 17465 17466 17467 17468 17469 17470 17471 17472 17473 17474 17475 17476 17477 17478 17479 17480 17481 17482 17483 17484 17485 17486 17487 17488 17489 17490 17491 17492 17493 17494 17495 17496 17497 17498 17499 17500 17501 17502 17503 17504 17505 17506 17507 17508 17509 17510 17511 17512 17513 17514 17515 17516 17517 17518 17519 17520 17521 17522 17523 17524 17525 17526 17527 17528 17529 17530 17531 17532 17533 17534 17535 17536 17537 17538 17539 17540 17541 17542 17543 17544 17545 17546 17547 17548 17549 17550 17551 17552 17553 17554 17555 17556 17557 17558 17559 17560 17561 17562 17563 17564 17565 17566 17567 17568 17569 17570 17571 17572 17573 17574 17575 17576 17577 17578 17579 17580 17581 17582 17583 17584 17585 17586 17587 17588 17589 17590 17591 17592 17593 17594 17595 17596 17597 17598 17599 17600 17601 17602 17603 17604 17605 17606 17607 17608 17609 17610 17611 17612 17613 17614 17615 17616 17617 17618 17619 17620 17621 17622 17623 17624 17625 17626 17627 17628 17629 17630 17631 17632 17633 17634 17635 17636 17637 17638 17639 17640 17641 17642 17643 17644 17645 17646 17647 17648 17649 17650 17651 17652 17653 17654 17655 17656 17657 17658 17659 17660 17661 17662 17663 17664 17665 17666 17667 17668 17669 17670 17671 17672 17673 17674 17675 17676 17677 17678 17679 17680 17681 17682 17683 17684 17685 17686 17687 17688 17689 17690 17691 17692 17693 17694 17695 17696 17697 17698 17699 17700 17701 17702 17703 17704 17705 17706 17707 17708 17709 17710 17711 17712 17713 17714 17715 17716 17717 17718 17719 17720 17721 17722 17723 17724 17725 17726 17727 17728 17729 17730 17731 17732 17733 17734 17735 17736 17737 17738 17739 17740 17741 17742 17743 17744 17745 17746 17747 17748 17749 17750 17751 17752 17753 17754 17755 17756 17757 17758 17759 17760 17761 17762 17763 17764 17765 17766 17767 17768 17769 17770 17771 17772 17773 17774 17775 17776 17777 17778 17779 17780 17781 17782 17783 17784 17785 17786 17787 17788 17789 17790 17791 17792 17793 17794 17795 17796 17797 17798 17799 17800 17801 17802 17803 17804 17805 17806 17807 17808 17809 17810 17811 17812 17813 17814 17815 17816 17817 17818 17819 17820 17821 17822 17823 17824 17825 17826 17827 17828 17829 17830 17831 17832 17833 17834 17835 17836 17837 17838 17839 17840 17841 17842 17843 17844 17845 17846 17847 17848 17849 17850 17851 17852 17853 17854 17855 17856 17857 17858 17859 17860 17861 17862 17863 17864 17865 17866 17867 17868 17869 17870 17871 17872 17873 17874 17875 17876 17877 17878 17879 17880 17881 17882 17883 17884 17885 17886 17887 17888 17889 17890 17891 17892 17893 17894 17895 17896 17897 17898 17899 17900 17901 17902 17903 17904 17905 17906 17907 17908 17909 17910 17911 17912 17913 17914 17915 17916 17917 17918 17919 17920 17921 17922 17923 17924 17925 17926 17927 17928 17929 17930 17931 17932 17933 17934 17935 17936 17937 17938 17939 17940 17941 17942 17943 17944 17945 17946 17947 17948 17949 17950 17951 17952 17953 17954 17955 17956 17957 17958 17959 17960 17961 17962 17963 17964 17965 17966 17967 17968 17969 17970 17971 17972 17973 17974 17975 17976 17977 17978 17979 17980 17981 17982 17983 17984 17985 17986 17987 17988 17989 17990 17991 17992 17993 17994 17995 17996 17997 17998 17999 18000 18001 18002 18003 18004 18005 18006 18007 18008 18009 18010 18011 18012 18013 18014 18015 18016 18017 18018 18019 18020 18021 18022 18023 18024 18025 18026 18027 18028 18029 18030 18031 18032 18033 18034 18035 18036 18037 18038 18039 18040 18041 18042 18043 18044 18045 18046 18047 18048 18049 18050 18051 18052 18053 18054 18055 18056 18057 18058 18059 18060 18061 18062 18063 18064 18065 18066 18067 18068 18069 18070 18071 18072 18073 18074 18075 18076 18077 18078 18079 18080 18081 18082 18083 18084 18085 18086 18087 18088 18089 18090 18091 18092 18093 18094 18095 18096 18097 18098 18099 18100 18101 18102 18103 18104 18105 18106 18107 18108 18109 18110 18111 18112 18113 18114 18115 18116 18117 18118 18119 18120 18121 18122 18123 18124 18125 18126 18127 18128 18129 18130 18131 18132 18133 18134 18135 18136 18137 18138 18139 18140 18141 18142 18143 18144 18145 18146 18147 18148 18149 18150 18151 18152 18153 18154 18155 18156 18157 18158 18159 18160 18161 18162 18163 18164 18165 18166 18167 18168 18169 18170 18171 18172 18173 18174 18175 18176 18177 18178 18179 18180 18181 18182 18183 18184 18185 18186 18187 18188 18189 18190 18191 18192 18193 18194 18195 18196 18197 18198 18199 18200 18201 18202 18203 18204 18205 18206 18207 18208 18209 18210 18211 18212 18213 18214 18215 18216 18217 18218 18219 18220 18221 18222 18223 18224 18225 18226 18227 18228 18229 18230 18231 18232 18233 18234 18235 18236 18237 18238 18239 18240 18241 18242 18243 18244 18245 18246 18247 18248 18249 18250 18251 18252 18253 18254 18255 18256 18257 18258 18259 18260 18261 18262 18263 18264 18265 18266 18267 18268 18269 18270 18271 18272 18273 18274 18275 18276 18277 18278 18279 18280 18281 18282 18283 18284 18285 18286 18287 18288 18289 18290 18291 18292 18293 18294 18295 18296 18297 18298 18299 18300 18301 18302 18303 18304 18305 18306 18307 18308 18309 18310 18311 18312 18313 18314 18315 18316 18317 18318 18319 18320 18321 18322 18323 18324 18325 18326 18327 18328 18329 18330 18331 18332 18333 18334 18335 18336 18337 18338 18339 18340 18341 18342 18343 18344 18345 18346 18347 18348 18349 18350 18351 18352 18353 18354 18355 18356 18357 18358 18359 18360 18361 18362 18363 18364 18365 18366 18367 18368 18369 18370 18371 18372 18373 18374 18375 18376 18377 18378 18379 18380 18381 18382 18383 18384 18385 18386 18387 18388 18389 18390 18391 18392 18393 18394 18395 18396 18397 18398 18399 18400 18401 18402 18403 18404 18405 18406 18407 18408 18409 18410 18411 18412 18413 18414 18415 18416 18417 18418 18419 18420 18421 18422 18423 18424 18425 18426 18427 18428 18429 18430 18431 18432 18433 18434 18435 18436 18437 18438 18439 18440 18441 18442 18443 18444 18445 18446 18447 18448 18449 18450 18451 18452 18453 18454 18455 18456 18457 18458 18459 18460 18461 18462 18463 18464 18465 18466 18467 18468 18469 18470 18471 18472 18473 18474 18475 18476 18477 18478 18479 18480 18481 18482 18483 18484 18485 18486 18487 18488 18489 18490 18491 18492 18493 18494 18495 18496 18497 18498 18499 18500 18501 18502 18503 18504 18505 18506 18507 18508 18509 18510 18511 18512 18513 18514 18515 18516 18517 18518 18519 18520 18521 18522 18523 18524 18525 18526 18527 18528 18529 18530 18531 18532 18533 18534 18535 18536 18537 18538 18539 18540 18541 18542 18543 18544 18545 18546 18547 18548 18549 18550 18551 18552 18553 18554 18555 18556 18557 18558 18559 18560 18561 18562 18563 18564 18565 18566 18567 18568 18569 18570 18571 18572 18573 18574 18575 18576 18577 18578 18579 18580 18581 18582 18583 18584 18585 18586 18587 18588 18589 18590 18591 18592 18593 18594 18595 18596 18597 18598 18599 18600 18601 18602 18603 18604 18605 18606 18607 18608 18609 18610 18611 18612 18613 18614 18615 18616 18617 18618 18619 18620 18621 18622 18623 18624 18625 18626 18627 18628 18629 18630 18631 18632 18633 18634 18635 18636 18637 18638 18639 18640 18641 18642 18643 18644 18645 18646 18647 18648 18649 18650 18651 18652 18653 18654 18655 18656 18657 18658 18659 18660 18661 18662 18663 18664 18665 18666 18667 18668 18669 18670 18671 18672 18673 18674 18675 18676 18677 18678 18679 18680 18681 18682 18683 18684 18685 18686 18687 18688 18689 18690 18691 18692 18693 18694 18695 18696 18697 18698 18699 18700 18701 18702 18703 18704 18705 18706 18707 18708 18709 18710 18711 18712 18713 18714 18715 18716 18717 18718 18719 18720 18721 18722 18723 18724 18725 18726 18727 18728 18729 18730 18731 18732 18733 18734 18735 18736 18737 18738 18739 18740 18741 18742 18743 18744 18745 18746 18747 18748 18749 18750 18751 18752 18753 18754 18755 18756 18757 18758 18759 18760 18761 18762 18763 18764 18765 18766 18767 18768 18769 18770 18771 18772 18773 18774 18775 18776 18777 18778 18779 18780 18781 18782 18783 18784 18785 18786 18787 18788 18789 18790 18791 18792 18793 18794 18795 18796 18797 18798 18799 18800 18801 18802 18803 18804 18805 18806 18807 18808 18809 18810 18811 18812 18813 18814 18815 18816 18817 18818 18819 18820 18821 18822 18823 18824 18825 18826 18827 18828 18829 18830 18831 18832 18833 18834 18835 18836 18837 18838 18839 18840 18841 18842 18843 18844 18845 18846 18847 18848 18849 18850 18851 18852 18853 18854 18855 18856 18857 18858 18859 18860 18861 18862 18863 18864 18865 18866 18867 18868 18869 18870 18871 18872 18873 18874 18875 18876 18877 18878 18879 18880 18881 18882 18883 18884 18885 18886 18887 18888 18889 18890 18891 18892 18893 18894 18895 18896 18897 18898 18899 18900 18901 18902 18903 18904 18905 18906 18907 18908 18909 18910 18911 18912 18913 18914 18915 18916 18917 18918 18919 18920 18921 18922 18923 18924 18925 18926 18927 18928 18929 18930 18931 18932 18933 18934 18935 18936 18937 18938 18939 18940 18941 18942 18943 18944 18945 18946 18947 18948 18949 18950 18951 18952 18953 18954 18955 18956 18957 18958 18959 18960 18961 18962 18963 18964 18965 18966 18967 18968 18969 18970 18971 18972 18973 18974 18975 18976 18977 18978 18979 18980 18981 18982 18983 18984 18985 18986 18987 18988 18989 18990 18991 18992 18993 18994 18995 18996 18997 18998 18999 19000 19001 19002 19003 19004 19005 19006 19007 19008 19009 19010 19011 19012 19013 19014 19015 19016 19017 19018 19019 19020 19021 19022 19023 19024 19025 19026 19027 19028 19029 19030 19031 19032 19033 19034 19035 19036 19037 19038 19039 19040 19041 19042 19043 19044 19045 19046 19047 19048 19049 19050 19051 19052 19053 19054 19055 19056 19057 19058 19059 19060 19061 19062 19063 19064 19065 19066 19067 19068 19069 19070 19071 19072 19073 19074 19075 19076 19077 19078 19079 19080 19081 19082 19083 19084 19085 19086 19087 19088 19089 19090 19091 19092 19093 19094 19095 19096 19097 19098 19099 19100 19101 19102 19103 19104 19105 19106 19107 19108 19109 19110 19111 19112 19113 19114 19115 19116 19117 19118 19119 19120 19121 19122 19123 19124 19125 19126 19127 19128 19129 19130 19131 19132 19133 19134 19135 19136 19137 19138 19139 19140 19141 19142 19143 19144 19145 19146 19147 19148 19149 19150 19151 19152 19153 19154 19155 19156 19157 19158 19159 19160 19161 19162 19163 19164 19165 19166 19167 19168 19169 19170 19171 19172 19173 19174 19175 19176 19177 19178 19179 19180 19181 19182 19183 19184 19185 19186 19187 19188 19189 19190 19191 19192 19193 19194 19195 19196 19197 19198 19199 19200 19201 19202 19203 19204 19205 19206 19207 19208 19209 19210 19211 19212 19213 19214 19215 19216 19217 19218 19219 19220 19221 19222 19223 19224 19225 19226 19227 19228 19229 19230 19231 19232 19233 19234 19235 19236 19237 19238 19239 19240 19241 19242 19243 19244 19245 19246 19247 19248 19249 19250 19251 19252 19253 19254 19255 19256 19257 19258 19259 19260 19261 19262 19263 19264 19265 19266 19267 19268 19269 19270 19271 19272 19273 19274 19275 19276 19277 19278 19279 19280 19281 19282 19283 19284 19285 19286 19287 19288 19289 19290 19291 19292 19293 19294 19295 19296 19297 19298 19299 19300 19301 19302 19303 19304 19305 19306 19307 19308 19309 19310 19311 19312 19313 19314 19315 19316 19317 19318 19319 19320 19321 19322 19323 19324 19325 19326 19327 19328 19329 19330 19331 19332 19333 19334 19335 19336 19337 19338 19339 19340 19341 19342 19343 19344 19345 19346 19347 19348 19349 19350 19351 19352 19353 19354 19355 19356 19357 19358 19359 19360 19361 19362 19363 19364 19365 19366 19367 19368 19369 19370 19371 19372 19373 19374 19375 19376 19377 19378 19379 19380 19381 19382 19383 19384 19385 19386 19387 19388 19389 19390 19391 19392 19393 19394 19395 19396 19397 19398 19399 19400 19401 19402 19403 19404 19405 19406 19407 19408 19409 19410 19411 19412 19413 19414 19415 19416 19417 19418 19419 19420 19421 19422 19423 19424 19425 19426 19427 19428 19429 19430 19431 19432 19433 19434 19435 19436 19437 19438 19439 19440 19441 19442 19443 19444 19445 19446 19447 19448 19449 19450 19451 19452 19453 19454 19455 19456 19457 19458 19459 19460 19461 19462 19463 19464 19465 19466 19467 19468 19469 19470 19471 19472 19473 19474 19475 19476 19477 19478 19479 19480 19481 19482 19483 19484 19485 19486 19487 19488 19489 19490 19491 19492 19493 19494 19495 19496 19497 19498 19499 19500 19501 19502 19503 19504 19505 19506 19507 19508 19509 19510 19511 19512 19513 19514 19515 19516 19517 19518 19519 19520 19521 19522 19523 19524 19525 19526 19527 19528 19529 19530 19531 19532 19533 19534 19535 19536 19537 19538 19539 19540 19541 19542 19543 19544 19545 19546 19547 19548 19549 19550 19551 19552 19553 19554 19555 19556 19557 19558 19559 19560 19561 19562 19563 19564 19565 19566 19567 19568 19569 19570 19571 19572 19573 19574 19575 19576 19577 19578 19579 19580 19581 19582 19583 19584 19585 19586 19587 19588 19589 19590 19591 19592 19593 19594 19595 19596 19597 19598 19599 19600 19601 19602 19603 19604 19605 19606 19607 19608 19609 19610 19611 19612 19613 19614 19615 19616 19617 19618 19619 19620 19621 19622 19623 19624 19625 19626 19627 19628 19629 19630 19631 19632 19633 19634 19635 19636 19637 19638 19639 19640 19641 19642 19643 19644 19645 19646 19647 19648 19649 19650 19651 19652 19653 19654 19655 19656 19657 19658 19659 19660 19661 19662 19663 19664 19665 19666 19667 19668 19669 19670 19671 19672 19673 19674 19675 19676 19677 19678 19679 19680 19681 19682 19683 19684 19685 19686 19687 19688 19689 19690 19691 19692 19693 19694 19695 19696 19697 19698 19699 19700 19701 19702 19703 19704 19705 19706 19707 19708 19709 19710 19711 19712 19713 19714 19715 19716 19717 19718 19719 19720 19721 19722 19723 19724 19725 19726 19727 19728 19729 19730 19731 19732 19733 19734 19735 19736 19737 19738 19739 19740 19741 19742 19743 19744 19745 19746 19747 19748 19749 19750 19751 19752 19753 19754 19755 19756 19757 19758 19759 19760 19761 19762 19763 19764 19765 19766 19767 19768 19769 19770 19771 19772 19773 19774 19775 19776 19777 19778 19779 19780 19781 19782 19783 19784 19785 19786 19787 19788 19789 19790 19791 19792 19793 19794 19795 19796 19797 19798 19799 19800 19801 19802 19803 19804 19805 19806 19807 19808 19809 19810 19811 19812 19813 19814 19815 19816 19817 19818 19819 19820 19821 19822 19823 19824 19825 19826 19827 19828 19829 19830 19831 19832 19833 19834 19835 19836 19837 19838 19839 19840 19841 19842 19843 19844 19845 19846 19847 19848 19849 19850 19851 19852 19853 19854 19855 19856 19857 19858 19859 19860 19861 19862 19863 19864 19865 19866 19867 19868 19869 19870 19871 19872 19873 19874 19875 19876 19877 19878 19879 19880 19881 19882 19883 19884 19885 19886 19887 19888 19889 19890 19891 19892 19893 19894 19895 19896 19897 19898 19899 19900 19901 19902 19903 19904 19905 19906 19907 19908 19909 19910 19911 19912 19913 19914 19915 19916 19917 19918 19919 19920 19921 19922 19923 19924 19925 19926 19927 19928 19929 19930 19931 19932 19933 19934 19935 19936 19937 19938 19939 19940 19941 19942 19943 19944 19945 19946 19947 19948 19949 19950 19951 19952 19953 19954 19955 19956 19957 19958 19959 19960 19961 19962 19963 19964 19965 19966 19967 19968 19969 19970 19971 19972 19973 19974 19975 19976 19977 19978 19979 19980 19981 19982 19983 19984 19985 19986 19987 19988 19989 19990 19991 19992 19993 19994 19995 19996 19997 19998 19999 20000 20001 20002 20003 20004 20005 20006 20007 20008 20009 20010 20011 20012 20013 20014 20015 20016 20017 20018 20019 20020 20021 20022 20023 20024 20025 20026 20027 20028 20029 20030 20031 20032 20033 20034 20035 20036 20037 20038 20039 20040 20041 20042 20043 20044 20045 20046 20047 20048 20049 20050 20051 20052 20053 20054 20055 20056 20057 20058 20059 20060 20061 20062 20063 20064 20065 20066 20067 20068 20069 20070 20071 20072 20073 20074 20075 20076 20077 20078 20079 20080 20081 20082 20083 20084 20085 20086 20087 20088 20089 20090 20091 20092 20093 20094 20095 20096 20097 20098 20099 20100 20101 20102 20103 20104 20105 20106 20107 20108 20109 20110 20111 20112 20113 20114 20115 20116 20117 20118 20119 20120 20121 20122 20123 20124 20125 20126 20127 20128 20129 20130 20131 20132 20133 20134 20135 20136 20137 20138 20139 20140 20141 20142 20143 20144 20145 20146 20147 20148 20149 20150 20151 20152 20153 20154 20155 20156 20157 20158 20159 20160 20161 20162 20163 20164 20165 20166 20167 20168 20169 20170 20171 20172 20173 20174 20175 20176 20177 20178 20179 20180 20181 20182 20183 20184 20185 20186 20187 20188 20189 20190 20191 20192 20193 20194 20195 20196 20197 20198 20199 20200 20201 20202 20203 20204 20205 20206 20207 20208 20209 20210 20211 20212 20213 20214 20215 20216 20217 20218 20219 20220 20221 20222 20223 20224 20225 20226 20227 20228 20229 20230 20231 20232 20233 20234 20235 20236 20237 20238 20239 20240 20241 20242 20243 20244 20245 20246 20247 20248 20249 20250 20251 20252 20253 20254 20255 20256 20257 20258 20259 20260 20261 20262 20263 20264 20265 20266 20267 20268 20269 20270 20271 20272 20273 20274 20275 20276 20277 20278 20279 20280 20281 20282 20283 20284 20285 20286 20287 20288 20289 20290 20291 20292 20293 20294 20295 20296 20297 20298 20299 20300 20301 20302 20303 20304 20305 20306 20307 20308 20309 20310 20311 20312 20313 20314 20315 20316 20317 20318 20319 20320 20321 20322 20323 20324 20325 20326 20327 20328 20329 20330 | #!/bin/sh
#
# rkhunter -- Scan the system for rootkits and other known security issues.
#
# Copyright (c) 2003-2014, Michael Boelen ( michael AT rootkit DOT nl )
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
#
#
# Unfortunately we must do some O/S checks at the very beginning,
# otherwise SunOS will complain about some of the ksh/bash syntax.
# By default the SunOS root account uses a simple Bourne shell,
# which does not work with RKH. So we exec to use the Bash shell
# if it is present, or the Korn shell which is usually installed
# by default on Solaris systems.
#
BSDOS=0
SUNOS=0
OPERATING_SYSTEM=`uname 2>/dev/null`
case "${OPERATING_SYSTEM}" in
*BSD|DragonFly)
BSDOS=1
;;
SunOS)
SUNOS=1
;;
esac
if [ $SUNOS -eq 1 ]; then
# Simple SunOS test of RANDOM to see if we are now running bash or ksh.
if [ -z "$RANDOM" ]; then
# If the 'which' output contains a space, then it is probably an error.
if [ -n "`which bash 2>/dev/null | grep -v ' '`" ]; then
exec bash $0 $*
elif [ -n "`which ksh 2>/dev/null | grep -v ' '`" ]; then
exec ksh $0 $*
else
echo "Unable to find the bash or ksh shell to run rkhunter."
exit 1
fi
exit 0
fi
fi
#
# Check to see if we are using the '--debug' option. If so, then
# we exec to log everything to the debug file.
#
if [ -n "`echo \"$*\" | grep '\-\-debug'`" ]; then
RKHDEBUGBASE="/tmp/rkhunter-debug"
#
# Ensure we create a random file name.
#
if [ -n "`which mktemp 2>/dev/null | grep -v ' '`" ]; then
RKHDEBUGFILE=`mktemp ${RKHDEBUGBASE}.XXXXXXXXXX`
elif [ -n "$RANDOM" ]; then
RKHDEBUGFILE="${RKHDEBUGBASE}.$RANDOM"
elif [ -n "`date +%N%s 2>/dev/null | grep '^[0-9][0-9]*$'`" ]; then
RKHDEBUGFILE="${RKHDEBUGBASE}.`date +%N%s%N`"
else
RKHDEBUGFILE="${RKHDEBUGBASE}.`date +%Y%m%d%H%M%S`"
fi
if [ -e "${RKHDEBUGFILE}" ]; then
if [ -f "${RKHDEBUGFILE}" -a ! -h "${RKHDEBUGFILE}" ]; then
rm -f "${RKHDEBUGFILE}" >/dev/null 2>&1
else
echo "Cannot use '--debug' option. \"${RKHDEBUGFILE}\" already exists, but it is not a file."
exit 1
fi
fi
DEBUG_OPT=1
exec 1>"${RKHDEBUGFILE}" 2>&1
chmod 600 "${RKHDEBUGFILE}" >/dev/null 2>&1
set -x
else
DEBUG_OPT=0
fi
#
# Now we must determine if we are using the Korn shell or not. If so,
# then we alias the 'echo' command and set ECHOOPT. For other shells,
# we try and determine the real shell being used, and test to see if
# the 'echo -e' command is valid or not. We set ECHOOPT accordingly.
#
#
# Unfortunately *BSD doesn't seem to allow capturing of unknown commands.
# So we must alias 'print' to something valid, but which will fail.
#
test $BSDOS -eq 1 && alias print=false
if [ "`print "rkh-ksh-string-test" 2>/dev/null`" = "rkh-ksh-string-test" ]; then
alias echo='print'
ECHOOPT="--"
MYSHELL=ksh
elif [ $SUNOS -eq 1 ]; then
# For Solaris, if we are not running ksh, then it must be bash.
MYSHELL=bash
ECHOOPT="-e"
else
#
# We want to get the actual shell used by this program, and
# so we need to test /bin/sh.
#
MYSHELL=/bin/sh
test -h ${MYSHELL} && MYSHELL=`readlink ${MYSHELL} 2>/dev/null`
MYSHELL=`basename ${MYSHELL} 2>/dev/null`
# Assume 'bash' if we have problems finding the real shell.
test -z "${MYSHELL}" && MYSHELL=bash
#
# Now test the 'echo -e' command.
#
if [ "`echo -e \"rkh-ksh\tstring-test\" 2>/dev/null`" = "rkh-ksh string-test" ]; then
ECHOOPT="-e"
else
ECHOOPT=""
fi
fi
#
# We now perform a similar test to see if 'echo -n', or "\c", is valid
# or not. Unfortunately on some systems both '-e' and '-n' are valid,
# but not together. The "\c" option works in these cases. So we set
# ECHON accordingly.
#
if [ "`echo -n -e \"rkh-ksh-string-test\" 2>/dev/null`" = "rkh-ksh-string-test" ]; then
ECHON="-n"
elif [ "`echo -e \"rkh-ksh-string-test\c\" 2>/dev/null`" = "rkh-ksh-string-test" ]; then
ECHON="c"
elif [ "`echo \"rkh-ksh-string-test\c\" 2>/dev/null`" = "rkh-ksh-string-test" ]; then
ECHON="c"
else
ECHON=""
fi
#
# Finally, we need to test the 'head' and 'tail' commands
# to see if they understand the '-n' option or not.
#
if head -n 1 </dev/null >/dev/null 2>&1; then
HEAD_OPT="-n "
else
HEAD_OPT="-"
fi
if tail -n 1 </dev/null >/dev/null 2>&1; then
TAIL_OPT="-n "
else
TAIL_OPT="-"
fi
######################################################################
#
# Global function definitions
#
######################################################################
display() {
#
# This function is used to display text messages on to the
# users screen, as well as in to the log file. The same
# message is written to both. However, the screen may have
# a coloured result (green for good, red for bad, etc), and
# the log file will have the time prefixed to the message and,
# optionally, additional information messages after the main
# message. All the messages are indexed in the language file.
#
# Syntax: display --to <destination> --type <type>
# [--screen-indent <n>] [--log-indent <n>]
# [--nl [<n>]] [--nl-after] [--log-nl] [--screen-nl] [--nonl]
# [--result <result> --color <colour>]
# <message index> [optional message arguments]
#
# where the destination can be one of SCREEN, LOG or SCREEN+LOG.
# The type can be one of PLAIN, INFO or WARNING.
# The language file will have all the current values.
#
# The --screen-indent and --log-indent options are used to
# forcibly indent a message.
# The --nl option causes a blank-line to be output before the
# message both on the screen and in the log file. A following
# number can be used to indicate how many blank lines should
# be displayed on the screen.
# The --log-nl option outputs a blank line only in the log file.
# The --screen-nl option outputs a blank line on the screen
# regardless of whether SCREEN was specified or not.
# The --nl-after option outputs a blank line on the screen after
# the message.
# The --nonl option is only to be used in special cases where we
# want the output of more than one message to appear on the same
# line. This is currently only used when trying to obtain the
# lock file. It only applies to PLAIN messages, and may not be
# supported on all systems (depending on whether 'echo -n' works
# or not).
#
#
# We first initialize some variables and then
# process the switches used.
#
WARN_MSG=0; NL=0; NLAFTER=0; LOGINDENT=0; SCREENINDENT=0
LOGNL=0; SCREENNL=0
WRITETO=''; TYPE=''; RESULT=''; COLOR=''; MSG=''
LINE1=''; LOGLINE1=''; SPACES=''; NONL=''
DISPLAY_LINE="display $*"
if [ $# -le 0 ]; then
echo "Error: Invalid display call - no arguments given"
return
fi
while [ $# -ge 1 ]; do
case "$1" in
--to)
case "$2" in
SCREEN|LOG|SCREEN+LOG)
WRITETO=$2
;;
*)
echo "Error: Invalid display destination: $2 Display line: ${DISPLAY_LINE}"
return
;;
esac
shift
;;
--type)
TYPE=`eval echo "\\$MSG_TYPE_$2"`
if [ -z "${TYPE}" -a "$2" != "PLAIN" ]; then
if [ $RKHLANGUPDT -eq 0 ]; then
echo "Error: Invalid display type: $2 Display line: ${DISPLAY_LINE}"
return
fi
fi
test "$2" = "WARNING" && WARN_MSG=1
shift
;;
--result)
RESULT=`eval echo "\\$MSG_RESULT_$2"`
if [ -z "${RESULT}" ]; then
if [ $RKHLANGUPDT -eq 0 ]; then
echo "Error: Invalid display result: $2 Display line: ${DISPLAY_LINE}"
return
fi
fi
shift
;;
--color)
if [ $COLORS -eq 1 ]; then
test -n "$2" && COLOR=`eval "echo \\${$2}"`
if [ -z "${COLOR}" ]; then
echo "Error: Invalid display color: $2 Display line: ${DISPLAY_LINE}"
return
fi
fi
shift
;;
--log-indent)
LOGINDENT=$2
if [ -z "${LOGINDENT}" ]; then
echo "Error: No --log-indent value given. Display line: ${DISPLAY_LINE}"
return
elif [ -z "`echo ${LOGINDENT} | grep '^[0-9]*$'`" ]; then
echo "Error: Invalid '--log-indent' value given: $2 Display line: ${DISPLAY_LINE}"
return
fi
shift
;;
--screen-indent)
SCREENINDENT=$2
if [ -z "${SCREENINDENT}" ]; then
echo "Error: No --screen-indent value given. Display line: ${DISPLAY_LINE}"
return
elif [ -z "`echo ${SCREENINDENT} | grep '^[0-9]*$'`" ]; then
echo "Error: Invalid '--screen-indent' value given: $2 Display line: ${DISPLAY_LINE}"
return
fi
shift
;;
--nl)
NL=1
case "$2" in
[0-9])
NL=$2
shift
;;
esac
;;
--log-nl)
LOGNL=1
;;
--screen-nl)
SCREENNL=1
;;
--nl-after)
NLAFTER=1
;;
--nonl)
NONL=$ECHON
;;
-*)
echo "Error: Invalid display option given: $1 Display line: ${DISPLAY_LINE}"
return
;;
*)
MSG=$1
shift
break
;;
esac
shift
done
#
# Before anything we must record if this is a warning message.
#
test $WARN_MSG -eq 1 && WARNING_COUNT=`expr ${WARNING_COUNT} + 1`
#
# For simplicity we now set variables as to whether the output
# goes to the screen and/or the log file. In some cases we do
# not need to output anything, and so can just return.
#
if [ $NOLOG -eq 1 ]; then
test "${WRITETO}" = "LOG" && return
test "${WRITETO}" = "SCREEN+LOG" && WRITETO="SCREEN"
fi
if [ $NOTTY -eq 1 ]; then
test "${WRITETO}" = "SCREEN" && return
test "${WRITETO}" = "SCREEN+LOG" && WRITETO="LOG"
fi
test "${WRITETO}" = "SCREEN" -o "${WRITETO}" = "SCREEN+LOG" && WRITETOTTY=1 || WRITETOTTY=0
test "${WRITETO}" = "LOG" -o "${WRITETO}" = "SCREEN+LOG" && WRITETOLOG=1 || WRITETOLOG=0
#
# Now check that the options we have been given make sense.
#
if [ $WRITETOTTY -eq 0 -a $WRITETOLOG -eq 0 ]; then
echo "Error: Invalid display destination: Display line: ${DISPLAY_LINE}"
return
elif [ $WRITETOTTY -eq 1 -a $COLORS -eq 1 -a -n "${RESULT}" -a -z "${COLOR}" ]; then
echo "Error: Invalid display - no color given: Display line: ${DISPLAY_LINE}"
return
fi
#
# We only allow no newline for PLAIN messages.
#
test -n "${TYPE}" && NONL=""
#
# If we want whitelisted results to be shown as white, or
# black for colour set two users, then change the colour now.
#
if [ $WLIST_IS_WHITE -eq 1 -a $WRITETOTTY -eq 1 -a $COLORS -eq 1 -a "${RESULT}" = "${MSG_RESULT_WHITELISTED}" ]; then
COLOR=$WHITE
fi
#
# We set the variable LINE1 to contain the first line of the message.
# For the log file we use the variable LOGLINE1. We also set
# where the language file is located. If a message cannot be found
# in the file, then we look in the English file. This will allow RKH
# to still work even when the language files change.
#
LANG_FILE="${DB_PATH}/i18n/${LANGUAGE}"
if [ -n "${MSG}" ]; then
LINE1=`grep ${GREP_OPT} "^${MSG}:" "${LANG_FILE}" 2>/dev/null | head ${HEAD_OPT}1 | cut -d: -f2-`
if [ $RKHCHKLOCALE -eq 1 ]; then
LINE1=`echo "${LINE1}" | ${ICONV_CMD} -f UTF-8 -t ${RKHCHRMAP} 2>/dev/null`
test $? -ne 0 && LINE1=""
fi
if [ -z "${LINE1}" ]; then
LANG_FILE="${DB_PATH}/i18n/en"
LINE1=`grep ${GREP_OPT} "^${MSG}:" "${LANG_FILE}" 2>/dev/null | head ${HEAD_OPT}1 | cut -d: -f2-`
if [ -z "${LINE1}" ]; then
echo "Error: Invalid display - keyword cannot be found: Display line: ${DISPLAY_LINE}"
return
fi
else
LINE1=`echo "${LINE1}" | sed -e 's/\`/\\\\\`/g'`
fi
test -n "${LINE1}" && LINE1=`eval "echo \"${LINE1}\" | sed -e 's/;/\\;/g'"`
fi
#
# At this point LINE1 is the text of the message. We have to
# see if the message is to be indented, and must prefix the
# time to log file messages. We must do the log file first
# because it uses LINE1.
#
if [ $WRITETOLOG -eq 1 ]; then
LOGLINE1=`date '+[%H:%M:%S]'`
test $NL -gt 0 -o $LOGNL -eq 1 && echo "${LOGLINE1}" >>"${RKHLOGFILE}"
if [ -n "${TYPE}" ]; then
LOGLINE1="${LOGLINE1} ${TYPE}: ${LINE1}"
else
test $LOGINDENT -gt 0 && SPACES=`echo "${BLANK_LINE}" | cut -c1-$LOGINDENT`
LOGLINE1="${LOGLINE1} ${SPACES}${LINE1}"
fi
fi
if [ $WRITETOTTY -eq 1 -a $SCREENINDENT -gt 0 ]; then
SPACES=`echo "${BLANK_LINE}" | cut -c1-$SCREENINDENT`
LINE1="${SPACES}${LINE1}"
fi
#
# We now check to see if a result is to be output. If it is,
# then we need to space-out the line and color the result.
#
if [ -n "${RESULT}" ]; then
if [ $WRITETOTTY -eq 1 ]; then
LINE1_NUM=`echo "${LINE1}" | wc -c | tr -d ' '`
NUM_SPACES=`expr 62 - ${LINE1_NUM}`
test $NUM_SPACES -lt 1 && NUM_SPACES=1
if [ $COLORS -eq 0 ]; then
SPACES=`echo "${BLANK_LINE}" | cut -c1-$NUM_SPACES`
LINE1="${LINE1}${SPACES}[ ${RESULT} ]"
else
LINE1="${LINE1}\033[${NUM_SPACES}C[ ${COLOR}${RESULT}${NORMAL} ]"
fi
fi
if [ $WRITETOLOG -eq 1 ]; then
LOGLINE1_NUM=`echo "${LOGLINE1}" | wc -c | tr -d ' '`
NUM_SPACES=`expr 62 - ${LOGLINE1_NUM}`
test $NUM_SPACES -lt 1 && NUM_SPACES=1
SPACES=`echo "${BLANK_LINE}" | cut -c1-$NUM_SPACES`
LOGLINE1="${LOGLINE1}${SPACES}[ ${RESULT} ]"
fi
elif [ $WRITETOTTY -eq 1 -a -n "${COLOR}" ]; then
LINE1="${COLOR}${LINE1}${NORMAL}"
fi
#
# We can now output the message. We start with any required blank
# lines, and then the first line. If this is a warning message we
# write to the log file any additional lines.
#
if [ $SCREENNL -eq 1 ]; then
test $QUIET -eq 0 -a $SHOWWARNINGSONLY -eq 0 -a $NOTTY -eq 0 && echo ""
fi
if [ $WRITETOTTY -eq 1 ]; then
NLLOOP=$NL
while test $NLLOOP -gt 0; do
echo ""
NLLOOP=`expr ${NLLOOP} - 1`
done
if [ "${NONL}" = "c" ]; then
echo $ECHOOPT "${LINE1}\c"
else
echo $NONL $ECHOOPT "${LINE1}"
fi
fi
if [ $WRITETOLOG -eq 1 ]; then
echo $ECHOOPT "${LOGLINE1}" >>"${RKHLOGFILE}"
if [ $WARN_MSG -eq 1 ]; then
test $SHOWWARNINGSONLY -eq 1 && echo $ECHOOPT "${LOGLINE1}" | cut -d' ' -f2-
LINE1=1
OLDIFS="${IFS}"
IFS=$IFSNL
for LOGLINE1 in `grep ${GREP_OPT} "^${MSG}:" "${LANG_FILE}" 2>/dev/null | cut -d: -f2-`; do
if [ $LINE1 -eq 1 ]; then
LINE1=0
continue
else
test $SHOWWARNINGSONLY -eq 1 && echo $ECHOOPT " ${LOGLINE1}"
echo $ECHOOPT " ${LOGLINE1}" >>"${RKHLOGFILE}"
fi
done
IFS="${OLDIFS}"
elif [ $SHOWWARNINGSONLY -eq 1 -a -n "`echo \"${LOGLINE1}\" | grep '^\[[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\] '`" ]; then
echo $ECHOOPT "${LOGLINE1}" | cut -d' ' -f2-
fi
fi
#
# Output a final blank line if requested to do so.
#
test $WRITETOTTY -eq 1 -a $NLAFTER -eq 1 && echo ""
return
}
name2text() {
#
# This function changes any spaces in a character string to '<SP>',
# tabs to '<TAB>' and any control characters to '?'. This allows
# pathnames to be seen more easily - especially if spaces or tabs
# are used.
#
# Whilst it would be nice to perform this function in 'display', we do
# not want the changes to occur for all messages. So we keep this a
# separate function, and only use it where necessary.
#
# Note that we must ensure that the 'echo' command does not interpret
# any part of the string.
#
echo $ECHOOPT "$*" | sed -e 's/ /<SP>/g; s/ /<TAB>/g' | tr -d '\n' | tr '[:cntrl:]' '?'
return
}
keypresspause() {
#
# This function will display a prompt message to the user.
#
if [ $SKIP_KEY_PRESS -eq 0 -a $QUIET -eq 0 ]; then
display --to SCREEN --type PLAIN --nl PRESSENTER
read RKHTMPVAR
test "${RKHTMPVAR}" = "s" -o "${RKHTMPVAR}" = "S" && SKIP_KEY_PRESS=1
fi
return
}
get_option() {
#
# This function is used to process configuration file options.
#
# Syntax: get_option (single | space-list | newline-list) <option name>
#
# The first parameter indicates if the option can occur on one
# or more lines in the configuration files. A 'space-list' is a
# space-separated list, and 'newline-list' is a newline-separated
# list. These will both typically be multiline. The second parameter
# is the configuration file option name.
#
# Single line options are typically numbers, a single word or pathname.
# Multiline options are usually pathnames, and will be a space-separated
# or newline-separated list. Space-separated lists are, obviously, not
# expected to contain any special characters such as a space.
#
# The function will output the final, non-expanded, option value.
# It will also return an error code. A code of zero indicates no
# problem, but a code of one indicates an error.
#
OPTMULTI="$1"
OPTNAME="$2"
ERRCODE=0
if [ -z "${OPTMULTI}" -o -z "${OPTNAME}" ]; then
echo "Error: Missing arguments in get_option function: $*" >&2
return 1
fi
#
# First see if the option is in the configuration files.
#
RKHTMPVAR2=`grep -h "^${OPTNAME}=" ${CONFIGFILE} ${LOCALCONFIGFILE} ${LOCALCONFDIRFILES}`
if [ -z "${RKHTMPVAR2}" ]; then
echo ""
return 0
fi
#
# We have an option, so process it.
#
case "${OPTMULTI}" in
single)
OPTVAR=`echo "${RKHTMPVAR2}" | tail ${TAIL_OPT}1 | sed -e "s/${OPTNAME}=//"`
# If the option is unset, then just return.
if [ -z "${OPTVAR}" -o "${OPTVAR}" = '""' -o "${OPTVAR}" = "''" ]; then
echo ""
return 0
fi
#
# We must handle any _CMD option specially because they may
# contain quote characters, and we do not want to remove these.
#
case "${OPTNAME}" in
*_CMD|WEBCMD|HASH_FUNC)
;;
*_OPTS)
#
# Rkhunter configuration options which are command options may
# begin with a hyphen ('-'). This can cause problems for the
# 'echo' command. To prevent this, the simplest solution is to
# append a space to the option value.
#
OPTVAR=`echo "${OPTVAR} " | tr -d '" ' | tr -d "'"`
test -n "`echo \"${OPTVAR} \" | grep '^-'`" && OPTVAR="${OPTVAR} "
;;
*)
OPTVAR=`echo "${OPTVAR}" | tr -d '" ' | tr -d "'"`
;;
esac
;;
space-list|newline-list)
#
# We must test whether the last line is set to the null string because
# a multiline option is reset by specifying the last setting as null.
#
RKHTMPVAR3=`echo "${RKHTMPVAR2}" | tail ${TAIL_OPT}1 | sed -e "s/${OPTNAME}=//"`
# If the option is unset, then just return.
if [ -z "${RKHTMPVAR3}" -o "${RKHTMPVAR3}" = '""' -o "${RKHTMPVAR3}" = "''" ]; then
echo ""
return 0
fi
OPTVAR=`echo "${RKHTMPVAR2}" | sed -e "s/${OPTNAME}=//"`
#
# If an option begins with a hyphen, then this will cause problems
# for the 'echo' command. So to prevent the problem we simply add
# a space to the option value. We must repeat this though if the
# variable is set again.
#
test -n "`echo \"${OPTVAR} \" | grep '^-'`" && OPTVAR="${OPTVAR} "
#
# Newline-separated list can contain virtually any character, so
# we leave them alone. But for space-separated lists we can be nice
# and compress spaces and remove quotes.
#
if [ "${OPTMULTI}" = "space-list" ]; then
OPTVAR=`echo "${OPTVAR}" | tr -s ' ' ' '`
OPTVAR=`echo "${OPTVAR}" | sed -e 's/^ *"* *//; s/ *"* *$//' | sed -e "s/^ *'* *//; s/ *'* *$//"`
test -n "`echo \"${OPTVAR} \" | grep '^-'`" && OPTVAR="${OPTVAR} "
#
# We only use the options given after the last blank line (if any).
#
if [ -n "${OPTVAR}" ]; then
#JH OPTVAR=`echo "${OPTVAR}" | awk 'BEGIN { RS="" }; END { print }'`
RKHLINES=`echo "${OPTVAR}" | wc -l | tr -d ' '`
OPTVAR=`echo "${OPTVAR}" | awk -v l=\`echo ${RKHLINES}\` '/./ { if (a) { a = a "\n" $0 } else a = $0 }; /^$/ { a = "" }; NR == l { print a }'`
test -n "`echo \"${OPTVAR} \" | grep '^-'`" && OPTVAR="${OPTVAR} "
fi
else
#
# For newline-separated lists, which will be pathnames, we are
# nice to the user and will strip off a leading single or double
# quote character *if* it also ends in the same quote character.
# Since these should be pathnames they should start with the
# '/' character. A quote as the first character implies that the
# user has quoted the pathname.
#
if [ -n "`echo \"${OPTVAR}\" | grep '^\".*\"$'`" ]; then
OPTVAR=`echo "${OPTVAR}" | sed -e 's/^"\(.*\)"$/\1/'`
elif [ -n "`echo \"${OPTVAR}\" | grep \"^'.*'$\"`" ]; then
OPTVAR=`echo "${OPTVAR}" | sed -e "s/^'\(.*\)'$/\1/"`
fi
fi
;;
*)
echo "Error: Invalid argument in get_option function: $*" >&2
return 1
;;
esac
echo "${OPTVAR}"
return 0
}
check_paths() {
#
# This function will check a supplied list of pathnames to
# ensure the files and directories exist. It will also
# check that directories such as '/' (root) are not present,
# nor are pathnames with unwanted characters.
#
# Syntax: check_paths <pathnames> <option_name> "[EXIST] [NOWILD] [NOBROKENLINK]"
#
# The function only checks the pathnames. It is not possible
# to modify the list in any way. The variable ERRCODE will be
# set to one if any pathname fails a check.
#
# The first parameter is the list of pathnames to check. The
# second parameter is the option name to be used in the error
# messages. The third parameter is a space-separated list
# indicating how strict the checks need to be with respect to
# the pathnames existence, whether wildcard characters are
# allowed, and whether symbolic links are allowed. The
# argument is a space-separated list of the words 'EXIST'
# (meaning the pathname must exist), 'NOWILD' (meaning that
# shell wildcard characters are not allowed), and 'NOBROKENLINK'
# (meaning that the pathname must not be a broken link).
# The words may be given in any order.
#
OPT_VALUE_OPT=$1
OPT_NAME=$2
STRICT=$3
test -z "${OPT_NAME}" && OPT_NAME=${OPT_VALUE_OPT}
OPT_VALUE=`eval echo \"\\$${OPT_VALUE_OPT}\"`
ERRCODE=0
test -z "${OPT_VALUE}" && return
MUSTEXIST=0
NOWILD=0
NOLINK=0
for RKHTMPVAR in ${STRICT}; do
case "${RKHTMPVAR}" in
EXIST)
MUSTEXIST=1
;;
NOWILD)
NOWILD=1
;;
NOBROKENLINK)
NOLINK=1
;;
*)
echo "Error: Invalid argument in check_paths function: $*" >&2
;;
esac
done
#
# If a pathname begins with a hyphen, then this will cause problems
# for the 'echo' command. Since we generally don't allow plain filenames,
# as opposed to a pathname, and these won't begin with a hyphen, we can
# test and reject these.
#
RKHTMPVAR=`echo "${OPT_VALUE} " | grep '^-'`
if [ -n "${RKHTMPVAR}" ]; then
ERRCODE=1
# We need to get RKHTMPVAR into a single line now, but we can't use a
# straight echo command here because that would expand any wildcards.
RKHTMPVAR=`make_space_list "${RKHTMPVAR}"`
echo "Invalid ${OPT_NAME} configuration option: Pathname begins with a hyphen: ${RKHTMPVAR}"
return
fi
#
# We must check the entry for wildcard characters first
# because the following 'for' command will expand them.
#
if [ $NOWILD -eq 1 ]; then
RKHTMPVAR=`echo "${OPT_VALUE}" | egrep '(^|[^\\])[][?*{}]'`
if [ -n "${RKHTMPVAR}" ]; then
ERRCODE=1
# We need to get RKHTMPVAR into a single line now, but we can't use a
# straight echo command here because that would expand the wildcards.
RKHTMPVAR=`make_space_list "${RKHTMPVAR}"`
echo "Invalid ${OPT_NAME} configuration option: Pathname contains wildcard characters: ${RKHTMPVAR}"
return
fi
fi
#
# Now check each pathname in the option.
#
# If this is a newline list option then we need to read a line at a time.
if [ -n "`echo \"${NEWLINE_LIST_OPTS}\" | grep \" ${OPT_NAME} \"`" ]; then
IFS=$IFSNL
fi
for FNAME in ${OPT_VALUE}; do
test -z "${FNAME}" && continue
#
# For some options we may have to remove the leading character.
#
#jh - no longer needed since we moved the check_paths for bindir paths.
#jh - code left here since we may need something very similar for overloaded options.
#jh - overloaded options - ALLOWPROCDELFILE PORT_PATH_WHITELIST RTKT_FILE_WHITELIST
#jh if [ "${OPT_NAME}" = "BINDIR" ]; then
#jh if [ -n "`echo \"${FNAME}\" | grep '^\+'`" ]; then
#jh FNAME=`echo "${FNAME}" | cut -c2-`
#jh fi
#jh fi
#
# First check for anything which contains just dots.
# Also check that '/' has not been set.
#
if [ -n "`echo \"${FNAME}\" | egrep '(^[./]*$)|[;&]|/\.\./'`" ]; then
ERRCODE=1
echo "Invalid ${OPT_NAME} configuration option: Invalid pathname: ${FNAME}"
continue
fi
#
# Next we check to see if it is a relative pathname.
#
if [ -n "`echo \"${FNAME}\" | grep '^[^/].*/'`" ]; then
ERRCODE=1
echo "Invalid ${OPT_NAME} configuration option: Relative pathname: ${FNAME}"
elif [ -z "`echo \"${FNAME}\" | grep '^/'`" ]; then
#
# Now we check to see if it is a simple file name.
#
#
# Simple file names are allowed for some options.
#
case "${OPT_NAME}" in
USER_FILEPROP_FILES_DIRS|*_CMD)
continue
;;
esac
ERRCODE=1
echo "Invalid ${OPT_NAME} configuration option: Simple filename: ${FNAME}"
else
#
# It's an absolute pathname. This could be a file, a directory,
# some other file type, or a non-existent name.
#
#
# This is as far as we go for some options. These pathnames may,
# or may not exist, or may be things other than just files and
# directories.
#
case "${OPT_NAME}" in
PKGMGR_NO_VRFY|EXISTWHITELIST|ALLOWDEVFILE)
continue
;;
esac
#
# Now test for the different file types.
#
if [ -f "${FNAME}" ]; then
case "${OPT_NAME}" in
ALLOWHIDDENDIR|TMPDIR|DBDIR|BINDIR|SCRIPTDIR|SSH_CONFIG_DIR|SUSPSCAN_DIRS|SUSPSCAN_TEMP|RTKT_DIR_WHITELIST)
ERRCODE=1
echo "Invalid ${OPT_NAME} configuration option: Not a directory: ${FNAME}"
;;
esac
elif [ -d "${FNAME}" ]; then
#
# For the ALLOWHIDDENFILE option we need to allow
# a hidden symbolic link to a directory.
#
test "${OPT_NAME}" = "ALLOWHIDDENFILE" -a -h "${FNAME}" && continue
case "${OPT_NAME}" in
ALLOWHIDDENFILE|RTKT_FILE_WHITELIST|WRITEWHITELIST|IMMUTWHITELIST|SCRIPTWHITELIST|LOGFILE|SYSLOG_CONFIG_FILE|INETD_CONF_PATH|XINETD_CONF_PATH|PASSWORD_FILE|OS_VERSION_FILE|IGNORE_PRELINK_DEP_ERR|MISSING_LOGFILES|EMPTY_LOGFILES|PORT_PATH_WHITELIST|*_CMD)
ERRCODE=1
echo "Invalid ${OPT_NAME} configuration option: Not a file: ${FNAME}"
;;
esac
elif [ -h "${FNAME}" ]; then
#
# Generally we will accept broken links since the code will
# simply not be able to use them. However, for some paths
# these are not allowed at all.
#
if [ $NOLINK -eq 1 ]; then
ERRCODE=1
echo "Invalid ${OPT_NAME} configuration option: Broken link found: ${FNAME}"
fi
elif [ -e "${FNAME}" ]; then
#
# This is as far as we go for the hidden files. A hidden
# 'file' can actually be anything other than a directory.
# Similarly, a rootkit 'file' could be something other than
# a regular file. So we allow them.
#
test "${OPT_NAME}" = "ALLOWHIDDENFILE" -o "${OPT_NAME}" = "RTKT_FILE_WHITELIST" && continue
ERRCODE=1
case "${OPT_NAME}" in
ALLOWHIDDENDIR|RTKT_DIR_WHITELIST|TMPDIR|DBDIR|BINDIR|SCRIPTDIR|SSH_CONFIG_DIR|SUSPSCAN_DIRS|SUSPSCAN_TEMP)
RKHTMPVAR2="directory"
;;
LOGFILE|SYSLOG_CONFIG_FILE|INETD_CONF_PATH|XINETD_CONF_PATH|PASSWORD_FILE|OS_VERSION_FILE|IGNORE_PRELINK_DEP_ERR|MISSING_LOGFILES|EMPTY_LOGFILES|PORT_PATH_WHITELIST|*_CMD)
RKHTMPVAR2="file"
;;
*)
RKHTMPVAR2="file or directory"
;;
esac
echo "Invalid ${OPT_NAME} configuration option: Not a ${RKHTMPVAR2}: ${FNAME}"
else
#
# Some pathnames don't need to exist.
#
test $MUSTEXIST -eq 0 && continue
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -z "`echo \"${EXISTWHITELIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
ERRCODE=1
echo "Invalid ${OPT_NAME} configuration option: Non-existent pathname: `name2text \"${FNAME}\"`"
fi
fi
fi
done
IFS=$RKHIFS
return
}
expand_paths() {
#
# This function will output an expanded list of pathnames.
#
# The first parameter is the variable name containing the
# newline-separated list of pathnames.
#
PATH_LIST=`eval echo \"\\$${1}\"`
test -z "${PATH_LIST}" && return
LIST=""
IFS=$IFSNL
for FNAME in ${PATH_LIST}; do
test -z "${FNAME}" && continue
LIST="${LIST}
${FNAME}"
done
IFS=$RKHIFS
echo "${LIST}" | sed -e '/^$/d'
return
}
make_space_list() {
#
# This function simply converts its argument into a space-separated list.
#
if [ "${ECHON}" = "c" ]; then
echo $ECHOOPT "${1}\c" | tr '\n' ' '
else
echo $ECHON $ECHOOPT "${1}" | tr '\n' ' '
fi
return
}
check_is_digit() {
#
# This function checks to see if an option is a valid
# number or not. Typically it must be 0 or 1.
#
# The first parameter is the variable name to check. The
# second parameter is the option name to be used in the error
# messages. An optional third parameter may be given to specify
# that other values are allowed. If this is set to 'ANY', then
# any positive number is allowed. If it is set to 'ANY1', then
# the number must be greater than zero.
#
OPT_VALUE=$1
OPT_NAME=$2
OTHERS=$3
test -z "${OPT_NAME}" && OPT_NAME=${OPT_VALUE}
test -z "${OTHERS}" && OTHERS=0
RKHTMPVAR=`eval echo "\"\\$${OPT_VALUE}\""`
ERRCODE=0
test -z "${RKHTMPVAR}" && return
#
# If ANY1 is given, then 0 is not a valid number.
#
if [ "${RKHTMPVAR}" = "0" -a "${OTHERS}" = "ANY1" ]; then
ERRCODE=1
echo "Invalid ${OPT_NAME} configuration option: not a valid number: ${RKHTMPVAR}"
elif [ "${RKHTMPVAR}" != "0" -a "${RKHTMPVAR}" != "1" ]; then
#
# Some options may allow a slightly different value.
#
if [ -n "${OTHERS}" ]; then
if [ "${OTHERS}" = "ANY" -a -n "`echo \"${RKHTMPVAR}\" | grep '^[0-9][0-9]*$'`" ]; then
return
elif [ "${OTHERS}" = "ANY1" -a -n "`echo \"${RKHTMPVAR}\" | grep '^[1-9][0-9]*$'`" ]; then
return
elif [ "${RKHTMPVAR}" = "${OTHERS}" ]; then
return
fi
fi
ERRCODE=1
echo "Invalid ${OPT_NAME} configuration option: not a valid number: ${RKHTMPVAR}"
fi
return
}
get_temp_file() {
#
# This function will find a unique pathname which can be
# used as a temporary file.
#
# It takes one parameter which is the pathname for the file,
# excluding the suffix. The function will return the pathname
# in TEMPFILE. The pathname itself is not created.
#
TEMPFILE=""
TEMPFILE_BASE=$1
if [ -n "${MKTEMP_CMD}" ]; then
TEMPFILE=`${MKTEMP_CMD} "${TEMPFILE_BASE}.XXXXXXXXXX"`
elif [ -n "$RANDOM" ]; then
TEMPFILE="${TEMPFILE_BASE}.$RANDOM"
elif [ $BSDOS -eq 1 ]; then
TEMPFILE="${TEMPFILE_BASE}.`date +%s`"
elif [ -n "`date +%N%s 2>/dev/null | grep '^[0-9][0-9]*$'`" ]; then
TEMPFILE="${TEMPFILE_BASE}.`date +%N%s%N`"
else
TEMPFILE="${TEMPFILE_BASE}.`date +%Y%m%d%H%M%S`"
fi
#
# Remove the file just in case it already exists!
#
rm -f "${TEMPFILE}" >/dev/null 2>&1
return
}
suckit_extra_checks() {
#
# This function carries out some extra checks of the suckit rootkit.
# There are 3 extra checks, but we only display the result after
# all the checks have completed. As such we store the result of
# each check in a variable, and display the final result based on
# the value of those variables.
#
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --log-indent 2 --nl ROOTKIT_ADD_SUCKIT_LOG
fi
ROOTKIT_COUNT=`expr ${ROOTKIT_COUNT} + 1`
#
# The first check tests the link count of the /sbin/init file.
# We use the NLINKS variable to indicate the test result:
# -1 means that no stat command was available
# 0 means that the stat command gave an error
# 1 is okay
# >1 means that suckit may be installed
#
NLINKS=-1
if [ -n "${STAT_CMD}" ]; then
if [ -n "`echo \"${STAT_CMD}\" | grep '\.pl$'`" ]; then
NLINKS=`${STAT_CMD} --nlink /sbin/init 2>/dev/null`
else
NLINKS=`${STAT_CMD} -c %h /sbin/init 2>/dev/null`
fi
test -z "${NLINKS}" && NLINKS=0
if [ $VERBOSE_LOGGING -eq 1 ]; then
if [ $NLINKS -eq 0 ]; then
display --to LOG --type PLAIN --result WARNING --log-indent 4 ROOTKIT_LINK_COUNT '/sbin/init'
elif [ $NLINKS -eq 1 ]; then
display --to LOG --type PLAIN --result OK --log-indent 4 ROOTKIT_LINK_COUNT '/sbin/init'
else
display --to LOG --type PLAIN --result WARNING --log-indent 4 ROOTKIT_LINK_COUNT '/sbin/init'
fi
fi
else
display --to LOG --type PLAIN --result SKIPPED --log-indent 4 ROOTKIT_LINK_COUNT '/sbin/init'
fi
#
# The next test checks to see if certain files are being
# hidden. These files have the '.xrk' or '.mem' suffix.
# The HIDDEN variable will be used to indicate the result:
# <null> is okay
# 'xrk' means that the 'xrk' suffix is hidden
# 'mem' means that the 'mem' suffix is hidden
#
HIDDEN=""
for EXT in xrk mem; do
get_temp_file "${RKHTMPDIR}/suckitexttest"
touch "${TEMPFILE}"
rm -f "${TEMPFILE}.${EXT}" >/dev/null 2>&1
mv "${TEMPFILE}" "${TEMPFILE}.${EXT}"
if [ ! -f "${TEMPFILE}.${EXT}" ]; then
if [ -n "${HIDDEN}" ]; then
HIDDEN="${HIDDEN} and ${EXT}"
else
HIDDEN=${EXT}
fi
fi
rm -f "${TEMPFILE}.${EXT}" >/dev/null 2>&1
done
if [ $VERBOSE_LOGGING -eq 1 ]; then
if [ -z "${HIDDEN}" ]; then
display --to LOG --type PLAIN --result NONE_FOUND --log-indent 4 ROOTKIT_ADD_SUCKIT_EXT
else
display --to LOG --type PLAIN --result FOUND --log-indent 4 ROOTKIT_ADD_SUCKIT_EXT
fi
fi
#
# Finally we perform a check using the skdet command, if it
# is present. The SKDET variable will be used to indicate
# the result:
# -1 means that skdet is not available
# 0 means that skdet found nothing
# 1 means that skdet found something
# 2 means that the version of skdet is unknown
#
# The variable SKDET_OUTPUT will contain any output from
# the command.
#
SKDET=-1
SKDET_OUTPUT=""
SKDET_CMD=`find_cmd skdet`
if [ -n "${SKDET_CMD}" ]; then
display --to LOG --type INFO FOUND_CMD 'skdet' "${SKDET_CMD}"
#
# We need to check the skdet version first.
#
SKDET=0
SKDETOPT=""
SKDETVER=`${SKDET_CMD} -v 2>&1 | grep '^skdet.v' | awk -F'.' '{ print $1 }'`
case "${SKDETVER}" in
*v0)
SKDETOPT="-a"
;;
*v1)
SKDETOPT="-c"
;;
*)
SKDET=2
SKDET_OUTPUT=`${SKDET_CMD} -v 2>&1`
;;
esac
if [ $SKDET -eq 0 ]; then
SKDET_OUTPUT=`${SKDET_CMD} ${SKDETOPT} 2>&1 | tr -s ' ' | grep -i 'invis'`
test -n "${SKDET_OUTPUT}" && SKDET=1
fi
if [ $VERBOSE_LOGGING -eq 1 ]; then
if [ $SKDET -eq 0 ]; then
display --to LOG --type PLAIN --result OK --log-indent 4 ROOTKIT_ADD_SUCKIT_SKDET
else
display --to LOG --type PLAIN --result WARNING --log-indent 4 ROOTKIT_ADD_SUCKIT_SKDET
fi
fi
elif [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result SKIPPED --log-indent 4 ROOTKIT_ADD_SUCKIT_SKDET
display --to LOG --type INFO NOT_FOUND_CMD 'skdet'
fi
#
# Now we can display the results.
#
if [ $NLINKS -eq 1 -a -z "${HIDDEN}" -a $SKDET -le 0 ]; then
display --to SCREEN+LOG --type PLAIN --result OK --color GREEN --screen-indent 4 --log-indent 2 ROOTKIT_ADD_SUCKIT
else
ROOTKIT_FAILED_COUNT=`expr ${ROOTKIT_FAILED_COUNT} + 1`
ROOTKIT_FAILED_NAMES="${ROOTKIT_FAILED_NAMES}Suckit Rookit (additional checks), "
display --to SCREEN+LOG --type WARNING --result WARNING --color RED --screen-indent 4 --log-indent 2 ROOTKIT_ADD_SUCKIT
if [ $NLINKS -eq -1 ]; then
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_ADD_SUCKIT_LINK_NOCMD
elif [ $NLINKS -eq 0 ]; then
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_LINK_COUNT_CMDERR "${STAT_CMD}" '/sbin/init'
elif [ $NLINKS -gt 1 ]; then
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_ADD_SUCKIT_LINK_FOUND "$NLINKS"
fi
if [ -n "${HIDDEN}" ]; then
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_ADD_SUCKIT_EXT_FOUND "${HIDDEN}"
fi
if [ $SKDET -eq 1 ]; then
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_ADD_SUCKIT_SKDET_FOUND "${SKDET_OUTPUT}"
elif [ $SKDET -eq 2 ]; then
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_ADD_SUCKIT_SKDET_VER "${SKDET_OUTPUT}"
fi
fi
return
}
scanrootkit() {
#
# This function performs the actual check for a rootkit.
# It uses the variables SCAN_ROOTKIT, SCAN_FILES, SCAN_DIRS
# and SCAN_KSYMS. These will have been set before the
# function is called.
#
SCAN_STATUS=0
ROOTKIT_COUNT=`expr ${ROOTKIT_COUNT} + 1`
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --nl ROOTKIT_FILES_DIRS_NAME_LOG "${SCAN_ROOTKIT}"
fi
#
# First check to see if any of the known files exist.
#
FILE_FOUND=""
for RKHTMPVAR2 in ${SCAN_FILES}; do
RKHTMPVAR=`echo "${RKHTMPVAR2}" | tr '%' ' '`
#
# If the option SCANROOTKITMODE is set to "THOROUGH" the scanrootkit() function
# will search (on a per rootkit basis) for filenames in all of the directories (as defined
# by the result of running 'find / -xdev'). While still not optimal, as it
# still searches for only file names as opposed to file contents, this is one step away
# from the rigidity of searching in known (evidence) or default (installation) locations.
#
# THIS OPTION SHOULD NOT BE ENABLED BY DEFAULT.
#
# You should only activate this feature as part of a more thorough investigation which
# should be based on relevant best practices and procedures.
# Apart from ameliorating the case with respect to functionality (e.g. reporting) this feature does not
# concern itself with efficiency so asking for improvements like whitelisting, de-duping or false-positives is
# out of the question.
#
# Enabling this feature implies you have the knowledge to interpret the results properly.
#
case "${SCANROOTKITMODE}" in
THOROUGH) # Search the whole filesystem
test -n "${BASENAME_CMD}" && FNAME=`${BASENAME_CMD} "${RKHTMPVAR}"` || FNAME=`echo "${RKHTMPVAR}" | sed -e 's:^.*/::'`
FILENAMES=`${FIND_CMD} / -xdev -name "${FNAME}"`
if [ -z "${FILENAMES}" ]; then
test $VERBOSE_LOGGING -eq 1 && display --to LOG --type PLAIN --result NOT_FOUND --log-indent 2 ROOTKIT_FILES_DIRS_FILE "`name2text \"${RKHTMPVAR}\"`"
else
FOUND=0
IFS=$IFSNL
for FNAME in ${FILENAMES}; do
if [ \( -f "${FNAME}" -a -s "${FNAME}" \) -o -b "${FNAME}" -o -c "${FNAME}" -o -h "${FNAME}" -o -p "${FNAME}" -o -S "${FNAME}" ]; then
FOUND=1
SCAN_STATUS=1
FILE_FOUND="${FILE_FOUND}
${FNAME}"
fi
done
IFS=$RKHIFS
if [ $VERBOSE_LOGGING -eq 1 ]; then
test $FOUND -eq 0 && FOUND="NOT_FOUND" || FOUND="FOUND"
display --to LOG --type PLAIN --result ${FOUND} --log-indent 2 ROOTKIT_FILES_DIRS_FILE "`name2text \"${RKHTMPVAR}\"`"
fi
fi
;;
*) # Scan ze old vay
if [ -f "${RKHTMPVAR}" ]; then
#
# We first check to see if the file is whitelisted. Note that we use
# the un-translated file name. This allows us to check for filenames
# with spaces, but without causing problems for our space-delimited test.
#
FNAMEGREP=`echo "${RKHTMPVAR2}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -n "`echo \"${RTKT_FILE_WHITELIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
display --to LOG --type INFO FILE_PROP_WL "`name2text \"${RKHTMPVAR}\"`" 'known_rkts'
else
SCAN_STATUS=1
FILE_FOUND="${FILE_FOUND}
${RKHTMPVAR}"
fi
test $VERBOSE_LOGGING -eq 1 && display --to LOG --type PLAIN --result FOUND --log-indent 2 ROOTKIT_FILES_DIRS_FILE "`name2text \"${RKHTMPVAR}\"`"
elif [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result NOT_FOUND --log-indent 2 ROOTKIT_FILES_DIRS_FILE "`name2text \"${RKHTMPVAR}\"`"
fi
;;
esac
done
#
# Next check to see if any of the directories exist.
#
DIR_FOUND=""
for RKHTMPVAR2 in ${SCAN_DIRS}; do
RKHTMPVAR=`echo "${RKHTMPVAR2}" | tr '%' ' '`
if [ -d "${RKHTMPVAR}" ]; then
#
# We first check to see if the directory is whitelisted. Note that we use
# the un-translated directory name. This allows us to check for directory
# names with spaces, but without causing problems for our space-delimited test.
#
FNAMEGREP=`echo "${RKHTMPVAR2}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -n "`echo \"${RTKT_DIR_WHITELIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
display --to LOG --type INFO FILE_PROP_WL_DIR "`name2text \"${RKHTMPVAR}\"`" 'known_rkts'
else
SCAN_STATUS=1
DIR_FOUND="${DIR_FOUND}
${RKHTMPVAR}"
fi
test $VERBOSE_LOGGING -eq 1 && display --to LOG --type PLAIN --result FOUND --log-indent 2 ROOTKIT_FILES_DIRS_DIR "`name2text \"${RKHTMPVAR}\"`"
elif [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result NOT_FOUND --log-indent 2 ROOTKIT_FILES_DIRS_DIR "`name2text \"${RKHTMPVAR}\"`"
fi
done
#
# Next check the ksyms or kallsyms file.
#
KSYM_FOUND=""
if [ -n "${SCAN_KSYMS}" ]; then
for KS in ${SCAN_KSYMS}; do
if [ -n "${KSYMS_FILE}" ]; then
FNAMEGREP=`echo "${KS}" | sed -e 's/\./\\\./g'`
if [ -n "`grep ${GREP_OPT} \"${FNAMEGREP}\" \"${KSYMS_FILE}\"`" ]; then
SCAN_STATUS=1
KSYM_FOUND="${KSYM_FOUND}
${KS}"
test $VERBOSE_LOGGING -eq 1 && display --to LOG --type PLAIN --result FOUND --log-indent 2 ROOTKIT_FILES_DIRS_KSYM "${KS}"
elif [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result NOT_FOUND --log-indent 2 ROOTKIT_FILES_DIRS_KSYM "${KS}"
fi
elif [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result SKIPPED --log-indent 2 ROOTKIT_FILES_DIRS_KSYM "${KS}"
fi
done
fi
#
# Now display the results.
#
if [ $SCAN_STATUS -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --result NOT_FOUND --color GREEN --screen-indent 4 NAME "${SCAN_ROOTKIT}"
else
ROOTKIT_FAILED_COUNT=`expr ${ROOTKIT_FAILED_COUNT} + 1`
ROOTKIT_FAILED_NAMES="${ROOTKIT_FAILED_NAMES}${SCAN_ROOTKIT}, "
display --to SCREEN+LOG --type WARNING --result WARNING --color RED --screen-indent 4 NAME "${SCAN_ROOTKIT}"
#
# Log any files, directories or ksyms found.
#
IFS=$IFSNL
FILE_FOUND=`echo "${FILE_FOUND}" | sed -e '/^$/d'`
for RKHTMPVAR in ${FILE_FOUND}; do
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_FILES_DIRS_FILE_FOUND "`name2text \"${RKHTMPVAR}\"`"
done
DIR_FOUND=`echo "${DIR_FOUND}" | sed -e '/^$/d'`
for RKHTMPVAR in ${DIR_FOUND}; do
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_FILES_DIRS_DIR_FOUND "`name2text \"${RKHTMPVAR}\"`"
done
KSYM_FOUND=`echo "${KSYM_FOUND}" | sed -e '/^$/d'`
for RKHTMPVAR in ${KSYM_FOUND}; do
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_FILES_DIRS_KSYM_FOUND "${RKHTMPVAR}"
done
IFS=$RKHIFS
fi
return
}
check_required_commands() {
#
# This function checks that the required commands are present
# on the system. The function is called twice: initially to check
# that we can at least start running rkhunter; and the second
# time after we have processed BINDIR to ensure that all the
# required commands are present. It takes one parameter used
# to indicate which list of commands to check.
#
LEAVE=0
if [ $1 -eq 1 ]; then
CMDDIR="${RKHROOTPATH}"
CMDNAMES="${ABSOLUTELY_REQUIRED_CMDS}"
else
CMDDIR="${BINPATHS}"
CMDNAMES="${REQCMDS}"
fi
for CMD in ${CMDNAMES}; do
SEEN=0
for DIR in ${CMDDIR}; do
if [ -f "${DIR}/${CMD}" -a -x "${DIR}/${CMD}" ]; then
SEEN=1
break
fi
done
if [ $SEEN -eq 0 ]; then
LEAVE=1
echo "The command '${CMD}' must be present on the system in order to run rkhunter."
fi
done
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
check_commands() {
#
# We check for some commands used in the tests. If the command
# is found then a variable including the command name is set.
# These commands are not 'required', so nothing happens if the
# command is not found. The commands can be defined in the
# configuration file, and a value of 'DISABLED' will cause a
# command to not exist. A value of 'BUILTIN' may be used for
# the 'stat' and 'readlink' commands, to indicate that the
# supplied scripts should be used. We have to handle the 'stat'
# command in a special way so that the perl module does not get
# used if the command is to be disabled.
#
LEAVE=0
for CMD in ${CMDLIST}; do
CMDNAME=`echo ${CMD} | tr '[:lower:]' '[:upper:]'`
CMDNAME="${CMDNAME}_CMD"
#
# See if the user has defined the command in
# the configuration file.
#
CFG_CMD=`get_option single "${CMDNAME}"` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${CFG_CMD}" ]; then
if [ "${CFG_CMD}" = "DISABLED" -o "${CFG_CMD}" = "BUILTIN" ]; then
eval ${CMDNAME}=\"${CFG_CMD}\"
else
MCMD=`echo "${CFG_CMD}" | cut -d' ' -f1`
#
# We must first check that the command name is valid.
# The user may have included globbing characters, or
# used multiple dots, and we do not allow that.
#
check_paths MCMD "${CMDNAME}" "EXIST NOWILD NOBROKENLINK"
if [ $ERRCODE -eq 1 ]; then
LEAVE=1
continue
fi
#
# Check that the command is executable.
#
if [ -n "`find_cmd ${MCMD}`" ]; then
eval ${CMDNAME}=\"${CFG_CMD}\"
else
CFG_CMD=""
fi
fi
fi
else
LEAVE=1
fi
#
# If the command has not been predefined, or is not
# executable, then go find the command to use.
#
test -z "${CFG_CMD}" && eval ${CMDNAME}=`find_cmd ${CMD}`
done
#
# We can only go this far really if there has been an error.
#
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
return
fi
fi
#
# If we cannot find a 'stat' command, or the supplied script is to
# be used, then we must check to see if perl is available. If it is,
# then the supplied 'stat' script can be used.
#
if [ -n "${PERL_CMD}" -a "${PERL_CMD}" != "DISABLED" ]; then
if [ -z "${STAT_CMD}" -o "${STAT_CMD}" = "BUILTIN" ]; then
if [ -r "${SCRIPT_PATH}/check_modules.pl" ]; then
MOD_INSTALLED=`${PERL_CMD} "${SCRIPT_PATH}/check_modules.pl" File::stat Getopt::Long 2>/dev/null | grep 'NOT installed'`
else
MOD_INSTALLED="module not found"
fi
if [ -z "${MOD_INSTALLED}" -a -r "${SCRIPT_PATH}/stat.pl" ]; then
STAT_CMD="${PERL_CMD} ${SCRIPT_PATH}/stat.pl"
else
STAT_CMD=""
fi
fi
elif [ "${STAT_CMD}" = "BUILTIN" ]; then
STAT_CMD=""
fi
#
# If the readlink command cannot be found, or it does not support
# the '-f' option, then we must use the supplied shell script.
#
if [ -z "${READLINK_CMD}" -o "${READLINK_CMD}" = "BUILTIN" ]; then
test -x "${SCRIPT_PATH}/readlink.sh" && READLINK_CMD="${SCRIPT_PATH}/readlink.sh" || READLINK_CMD=""
elif [ -n "`${READLINK_CMD} -f \"${SCRIPT_PATH}/readlink.sh\" 2>&1 >/dev/null`" ]; then
test -x "${SCRIPT_PATH}/readlink.sh" && READLINK_CMD="${SCRIPT_PATH}/readlink.sh" || READLINK_CMD=""
fi
test -n "${READLINK_CMD}" && HAVE_READLINK=1
#
# For Solaris systems we should use the 'gstrings' command
# rather than 'strings', if it is available. Similarly we
# should use 'gawk' or 'nawk' if it is available rather
# than 'awk'.
#
if [ $SUNOS -eq 1 ]; then
if [ "${STRINGS_CMD}" != "DISABLED" ]; then
RKHTMPVAR=`find_cmd gstrings`
test -n "${RKHTMPVAR}" && STRINGS_CMD="${RKHTMPVAR}"
fi
AWK_CMD=`find_cmd gawk`
if [ -z "${AWK_CMD}" ]; then
AWK_CMD=`find_cmd nawk`
if [ -z "${AWK_CMD}" ]; then
AWK_CMD=`find_cmd /usr/xpg4/bin/awk`
if [ -z "${AWK_CMD}" ]; then
AWK_CMD="awk"
fi
fi
fi
else
AWK_CMD="awk"
fi
#
# Finally we must remove all the DISABLED commands.
#
for CMD in ${CMDLIST}; do
RKHTMPVAR=`echo ${CMD} | tr '[:lower:]' '[:upper:]'`
RKHTMPVAR="${RKHTMPVAR}_CMD"
RKHTMPVAR2=`eval echo "\\$${RKHTMPVAR}"`
test "${RKHTMPVAR2}" = "DISABLED" -o "${RKHTMPVAR2}" = "BUILTIN" && eval ${RKHTMPVAR}=\"\"
done
return
}
get_installdir_option() {
#
# This function obtains the RKH installation directory. It must
# be set by the installer script, and has no default.
#
LEAVE=0
RKHINSTALLDIR=`get_option single INSTALLDIR` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -z "${RKHINSTALLDIR}" ]; then
LEAVE=1
echo "Invalid INSTALLDIR configuration option - no installation directory specified."
elif [ ! -d "${RKHINSTALLDIR}" ]; then
LEAVE=1
echo "Installation directory does not exist: ${RKHINSTALLDIR}"
elif [ ! -r "${RKHINSTALLDIR}" ]; then
LEAVE=1
echo "Installation directory is not readable: ${RKHINSTALLDIR}"
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_language_option() {
#
# First get the option from the command-line or the
# configuration file, and do a simple check on whether
# it is empty or a space.
#
LEAVE=0
if [ -n "${LANGUAGE}" ]; then
LANGUAGE=`echo "${LANGUAGE}" | tr -d '" ' | tr -d "'"`
if [ -z "${LANGUAGE}" ]; then
LEAVE=1
echo "Invalid '--language' option - no language given."
fi
else
LANGUAGE=`get_option single LANGUAGE` || exit 1
test $ERRCODE -eq 1 && LEAVE=1
fi
#
# If no language has been set, then use English.
#
test -z "${LANGUAGE}" && LANGUAGE="en"
#
# Now check that the language is available.
#
if [ ! -d "${DB_PATH}/i18n" ]; then
LEAVE=1
echo "The internationalisation directory does not exist: ${DB_PATH}/i18n"
fi
#
# If we are using the '--update' option, then the language files
# will be installed if they are missing. As such, we cannot check
# them here.
#
if [ $LEAVE -eq 0 ]; then
if [ ! -s "${DB_PATH}/i18n/${LANGUAGE}" -a "${LANGUAGE}" != "en" ]; then
if [ $UPDATE_ONLY -eq 1 ]; then
RKHLANGUPDT=1
else
LEAVE=1
echo "The language specified is not available: ${LANGUAGE}"
echo "Use the command 'rkhunter --lang en --list languages' to see the list of available languages."
fi
elif [ ! -s "${DB_PATH}/i18n/en" ]; then
if [ $UPDATE_ONLY -eq 1 ]; then
RKHLANGUPDT=1
else
LEAVE=1
echo "The English language file must be present: ${DB_PATH}/i18n/en"
echo "If it has been deleted, then you will need to run 'rkhunter --update' with no other options."
fi
fi
fi
#
# Next sort out the locale used if the language is German.
#
if [ "${LANGUAGE}" = "de" ]; then
ICONV_CMD=`find_cmd iconv`
LOCALE_CMD=`find_cmd locale`
if [ -n "${ICONV_CMD}" -a -n "${LOCALE_CMD}" ]; then
RKHCHRMAP=`${LOCALE_CMD} charmap 2>/dev/null`
test -n "${RKHCHRMAP}" && RKHCHKLOCALE=1
fi
fi
#
# Finally, find out what languages the user wants to be updated.
# We add in the default language, and 'en', if they have not
# been specified.
#
if [ $UPDATE -eq 1 ]; then
UPDATE_LANG=`get_option space-list UPDATE_LANG` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${UPDATE_LANG}" ]; then
if [ -z "`echo \" ${UPDATE_LANG} \" | grep \" ${LANGUAGE} \"`" ]; then
UPDATE_LANG="${UPDATE_LANG} ${LANGUAGE}"
fi
if [ -z "`echo \" ${UPDATE_LANG} \" | grep ' en '`" ]; then
UPDATE_LANG="${UPDATE_LANG} en"
fi
fi
else
LEAVE=1
fi
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_logfile_option() {
#
# First get the option from the command-line or the
# configuration file, and do a simple check on whether
# it is empty or a space.
#
LEAVE=0
if [ -n "${RKHLOGFILE}" ]; then
RKHLOGFILE=`echo "${RKHLOGFILE}" | tr -d '" ' | tr -d "'"`
if [ -z "${RKHLOGFILE}" ]; then
LEAVE=1
echo "Invalid '--logfile' option - no logfile name given."
fi
else
RKHLOGFILE=`get_option single LOGFILE` || exit 1
if [ $ERRCODE -eq 0 ]; then
check_paths RKHLOGFILE LOGFILE "NOWILD NOBROKENLINK"
if [ $ERRCODE -eq 0 ]; then
if [ -z "${RKHLOGFILE}" ]; then
RET_CODE=1
RKHLOGFILE="${DFLT_LOGFILE}"
echo "The default logfile will be used: ${RKHLOGFILE}"
fi
else
LEAVE=1
fi
else
LEAVE=1
fi
fi
#
# Now check that the given option is usable.
#
if [ $LEAVE -eq 1 ]; then
:
elif [ "${RKHLOGFILE}" = "/dev/null" ]; then
APPEND_LOG=0
else
LOGDIR=`echo "${RKHLOGFILE}" | sed -e 's:/[^/][^/]*$::'`
if [ -z "`echo \"${LOGDIR}\" | grep '/'`" ]; then
LOGDIR="."
fi
if [ "${LOGDIR}" = "${RKHLOGFILE}" ]; then
LEAVE=1
echo "No log filename given: ${RKHLOGFILE}"
elif [ ! -e "${LOGDIR}" ]; then
LEAVE=1
echo "Logfile directory does not exist: ${RKHLOGFILE}"
elif [ ! -d "${LOGDIR}" ]; then
LEAVE=1
echo "Logfile directory is not a directory: ${RKHLOGFILE}"
elif [ ! -w "${LOGDIR}" ]; then
LEAVE=1
echo "Logfile directory is not writable: ${RKHLOGFILE}"
elif [ ! -r "${LOGDIR}" ]; then
LEAVE=1
echo "Logfile directory is not readable: ${RKHLOGFILE}"
elif [ -h "${RKHLOGFILE}" ]; then
LEAVE=1
echo "Logfile is a symbolic link: ${RKHLOGFILE}"
echo "This is a security problem. The link points to another file, and that file is about to be modified by rkhunter."
elif [ -e "${RKHLOGFILE}" -a ! -f "${RKHLOGFILE}" ]; then
LEAVE=1
echo "Logfile already exists but it is not a file: ${RKHLOGFILE}"
fi
fi
#
# Now check whether we should append to the logfile
# or overwrite it. We check the configuration file
# option, if it is given, and ensure that it is valid.
#
if [ $APPEND_OPT -eq 0 ]; then
APPEND_LOG=`get_option single APPEND_LOG` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${APPEND_LOG}" ]; then
check_is_digit APPEND_LOG
test $ERRCODE -eq 1 && LEAVE=1
else
APPEND_LOG=0
fi
else
LEAVE=1
fi
fi
#
# Finally, check if the logfile should be copied if
# there were any errors or warnings. Obviously no
# copy is done if no logfile is used.
#
RKHTMPVAR=`get_option single COPY_LOG_ON_ERROR` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${RKHTMPVAR}" ]; then
check_is_digit RKHTMPVAR COPY_LOG_ON_ERROR
if [ $ERRCODE -eq 0 ]; then
COPY_LOG_ON_ERROR=$RKHTMPVAR
else
LEAVE=1
fi
else
COPY_LOG_ON_ERROR=0
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_tmpdir_option() {
#
# First get the option from the command-line or the
# configuration file, and do a simple check on whether
# it is empty or a space.
#
LEAVE=0
if [ -n "${RKHTMPDIR}" ]; then
RKHTMPDIR=`echo "${RKHTMPDIR}" | tr -d '" ' | tr -d "'"`
if [ -z "${RKHTMPDIR}" ]; then
LEAVE=1
echo "Invalid '--tmpdir' option - no directory name given."
fi
else
RKHTMPDIR=`get_option single TMPDIR` || exit 1
if [ $ERRCODE -eq 0 ]; then
check_paths RKHTMPDIR TMPDIR "NOWILD NOBROKENLINK EXIST"
if [ $ERRCODE -eq 0 ]; then
if [ -z "${RKHTMPDIR}" ]; then
RET_CODE=1
RKHTMPDIR="${RKHINSTALLDIR}/lib/rkhunter/tmp"
echo "The default temporary directory will be used: ${RKHTMPDIR}"
fi
else
LEAVE=1
fi
else
LEAVE=1
fi
fi
#
# Now check that the given option is usable.
#
if [ $LEAVE -eq 1 ]; then
:
elif [ ! -e "${RKHTMPDIR}" ]; then
LEAVE=1
echo "Temporary directory does not exist: ${RKHTMPDIR}"
elif [ ! -d "${RKHTMPDIR}" ]; then
LEAVE=1
echo "Temporary directory is not a directory: ${RKHTMPDIR}"
elif [ ! -w "${RKHTMPDIR}" ]; then
LEAVE=1
echo "Temporary directory is not writable: ${RKHTMPDIR}"
elif [ ! -r "${RKHTMPDIR}" ]; then
LEAVE=1
echo "Temporary directory is not readable: ${RKHTMPDIR}"
elif [ "${RKHTMPDIR}" = "/tmp" -o "${RKHTMPDIR}" = "/var/tmp" ]; then
LEAVE=1
echo "Do not use ${RKHTMPDIR} as the temporary directory."
echo "This directory will be used by rkhunter to contain system files, so the directory must be secure."
elif [ "${RKHTMPDIR}" = "/etc" ]; then
LEAVE=1
echo "Do not use ${RKHTMPDIR} as the temporary directory."
echo "This directory will be used by rkhunter to copy and delete certain system files."
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_dbdir_option() {
#
# First get the option from the command-line or the
# configuration file, and do a simple check on whether
# it is empty or a space.
#
LEAVE=0
if [ -n "${DB_PATH}" ]; then
DB_PATH=`echo "${DB_PATH}" | tr -d '" ' | tr -d "'"`
if [ -z "${DB_PATH}" ]; then
LEAVE=1
echo "Invalid '--dbdir' option - no directory name given."
fi
else
DB_PATH=`get_option single DBDIR` || exit 1
if [ $ERRCODE -eq 0 ]; then
check_paths DB_PATH DBDIR "NOWILD EXIST NOBROKENLINK"
if [ $ERRCODE -eq 0 ]; then
if [ -z "${DB_PATH}" ]; then
RET_CODE=1
DB_PATH="${RKHINSTALLDIR}/lib/rkhunter/db"
echo "The default database directory will be used: ${DB_PATH}"
fi
else
LEAVE=1
fi
else
LEAVE=1
fi
fi
#
# Now check that the given option is usable.
#
if [ $LEAVE -eq 1 ]; then
:
elif [ ! -e "${DB_PATH}" ]; then
LEAVE=1
echo "Database directory does not exist: ${DB_PATH}"
elif [ ! -d "${DB_PATH}" ]; then
LEAVE=1
echo "Database directory is not a directory: ${DB_PATH}"
elif [ ! -r "${DB_PATH}" ]; then
LEAVE=1
echo "Database directory is not readable: ${DB_PATH}"
elif [ $PROP_UPDATE -eq 1 -o $UPDATE -eq 1 -o $CONFIG_CHECK -eq 1 ]; then
if [ ! -w "${DB_PATH}" ]; then
LEAVE=1
echo "Database directory is not writable: ${DB_PATH}"
fi
fi
if [ $LEAVE -eq 0 ]; then
RKHDAT_FILE="${DB_PATH}/rkhunter.dat"
RKH_FILEPROP_LIST="${DB_PATH}/rkhunter_prop_list.dat"
else
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
add_extra_dirs() {
#
# This functions takes care of any additional directories
# that may exist on some systems. After the function is called
# the value of EXTRA_DIRS must be added to whatever variable
# is being used.
#
EXTRA_DIRS=""
if [ $SUNOS -eq 1 ]; then
#
# Add in some other directories, and those which
# contain the Solaris 'companion' software.
#
test -d /usr/gnu && EXTRA_DIRS="${EXTRA_DIRS} /usr/gnu/bin /usr/gnu/sbin /usr/gnu/libexec"
test -d /usr/sfw && EXTRA_DIRS="${EXTRA_DIRS} /usr/sfw/bin /usr/sfw/sbin /usr/sfw/libexec"
test -d /opt/sfw && EXTRA_DIRS="${EXTRA_DIRS} /opt/sfw/bin /opt/sfw/sbin /opt/sfw/libexec"
test -d /usr/xpg4/bin && EXTRA_DIRS="${EXTRA_DIRS} /usr/xpg4/bin"
test -d /usr/ccs/bin && EXTRA_DIRS="${EXTRA_DIRS} /usr/ccs/bin"
test -d /usr/5bin -a ! -h /usr/5bin && EXTRA_DIRS="${EXTRA_DIRS} /usr/5bin"
test -d /usr/ucb && EXTRA_DIRS="${EXTRA_DIRS} /usr/ucb"
#
# OpenSolaris distributions (e.g. BeleniX) may use
# other directories.
#
test -d /usr/foss && EXTRA_DIRS="${EXTRA_DIRS} /usr/foss/bin /usr/foss/sbin /usr/foss/libexec"
elif [ $BSDOS -eq 1 ]; then
test -d /usr/pkg && EXTRA_DIRS="${EXTRA_DIRS} /usr/pkg/bin /usr/pkg/sbin /usr/pkg/libexec"
elif [ $MACOSX -eq 1 ]; then
#
# Cater for Fink (Mac OS X) additional software.
#
test -d /sw && EXTRA_DIRS="${EXTRA_DIRS} /sw/bin /sw/sbin"
elif [ $IRIXOS -eq 1 ]; then
test -d /usr/ucb && EXTRA_DIRS="${EXTRA_DIRS} /usr/ucb"
test -d /usr/freeware && EXTRA_DIRS="${EXTRA_DIRS} /usr/freeware/bin /usr/freeware/sbin"
test -d /usr/xpg4/bin && EXTRA_DIRS="${EXTRA_DIRS} /usr/xpg4/bin"
elif [ -f "/etc/GoboLinuxVersion" ]; then
#
# We have no other easy way of detecting GoboLinux.
# It has a peculiar filesystem layout, so we need to
# add in this little bit of support to help it work
# with RKH.
#
test -d "/System/Links/Executables" && EXTRA_DIRS="${EXTRA_DIRS} /System/Links/Executables"
fi
#
# Finally check if there are any optional
# bin and sbin directories present.
#
test -d /opt && EXTRA_DIRS="${EXTRA_DIRS} /opt/bin /opt/sbin"
test -d /usr/opt && EXTRA_DIRS="${EXTRA_DIRS} /usr/opt/bin /usr/opt/sbin"
return
}
get_bindir_option() {
#
# First get the option from the command-line or the
# configuration file, and do a simple check on whether
# it is empty or a space.
#
LEAVE=0
if [ $BINDIR_OPT -eq 1 ]; then
BINPATHS=`echo "${BINPATHS}" | tr -d '"' | tr -d "'" | tr -s ' ' ' '`
if [ "${BINPATHS}" = " " ]; then
LEAVE=1
echo "Invalid '--bindir' option - no directory names given."
fi
else
BINPATHS=`get_option space-list BINDIR` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -z "${BINPATHS}" ]; then
BINPATHS="${DFLT_BINPATHS}"
#
# Under some OS's /bin is a link to /usr/bin, so
# there is no need to look in it.
#
if [ $SUNOS -eq 1 -o $IRIXOS -eq 1 -o "${OPERATING_SYSTEM}" = "AIX" ]; then
if [ -h "/bin" ]; then
RKHTMPVAR=""
for DIR in ${BINPATHS}; do
test "${DIR}" != "/bin" && RKHTMPVAR="${RKHTMPVAR} ${DIR}"
done
BINPATHS=`echo ${RKHTMPVAR}`
fi
fi
add_extra_dirs
BINPATHS="${BINPATHS}${EXTRA_DIRS}"
fi
else
LEAVE=1
fi
fi
#
# The BINPATHS list is prepended with the root PATH. However,
# any specified BINDIR directories beginning with a '+' will
# be prepended before the root PATH.
#
# Once that has been done, we check that each directory begins
# with a '/'. We remove any non-existent directories, but we do
# not flag this as an error. We also remove any duplicate directories.
#
if [ $LEAVE -eq 0 ]; then
RKHTMPVAR=""
PREPEND_PATHS=""
for DIR in ${BINPATHS}; do
if [ -n "`echo ${DIR} | grep '^\+'`" ]; then
DIR=`echo ${DIR} | cut -c2-`
PREPEND_PATHS="${PREPEND_PATHS} ${DIR}"
fi
done
PREPEND_PATHS=`echo ${PREPEND_PATHS}`
for DIR in ${PREPEND_PATHS} ${RKHROOTPATH} ${BINPATHS}; do
if [ -n "`echo ${DIR} | grep '^\+'`" ]; then
# These will already be in PREPEND_PATHS.
continue
elif [ -z "`echo ${DIR} | grep '^/'`" ]; then
LEAVE=1
test $BINDIR_OPT -eq 1 && RKHTMPVAR2="'--bindir'" || RKHTMPVAR2="BINDIR configuration"
echo "Invalid ${RKHTMPVAR2} option: Invalid directory found: ${DIR}"
elif [ -e "${DIR}" ]; then
if [ -d "${DIR}" ]; then
test -h "${DIR}" && BINISLINK=1
DIR=`echo "${DIR}" | tr -s '/' | sed -e 's:/$::'`
if [ -z "`echo \" ${RKHTMPVAR} \" | grep \" ${DIR} \"`" ]; then
RKHTMPVAR="${RKHTMPVAR} ${DIR}"
fi
else
LEAVE=1
test $BINDIR_OPT -eq 1 && RKHTMPVAR2="'--bindir'" || RKHTMPVAR2="BINDIR configuration"
echo "Invalid ${RKHTMPVAR2} option: Not a directory: ${DIR}"
fi
fi
done
if [ $LEAVE -eq 0 ]; then
BINPATHS=`echo ${RKHTMPVAR}`
test $BINDIR_OPT -eq 1 && RKHTMPVAR="--bindir" || RKHTMPVAR="BINDIR"
check_paths BINPATHS "${RKHTMPVAR}" "NOWILD"
test $ERRCODE -eq 1 && LEAVE=1
else
# We need to set something for the remaining checks.
BINPATHS="${DFLT_BINPATHS}"
fi
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_scriptdir_option() {
#
# Get the value from the configuration file, and do a simple
# check on whether it is empty or a space.
#
# Note: The installer will set this option. As such there
# is no default.
#
LEAVE=0
SCRIPT_PATH=`get_option single SCRIPTDIR` || exit 1
if [ $ERRCODE -eq 0 ]; then
check_paths SCRIPT_PATH SCRIPTDIR "NOWILD EXIST NOBROKENLINK"
if [ $ERRCODE -eq 0 ]; then
if [ -z "${SCRIPT_PATH}" ]; then
LEAVE=1
echo "The SCRIPTDIR configuration option has not been set by the installer."
fi
else
LEAVE=1
fi
else
LEAVE=1
fi
#
# Now check that the given option is usable.
#
if [ $LEAVE -eq 1 ]; then
:
elif [ ! -r "${SCRIPT_PATH}" ]; then
LEAVE=1
echo "Script directory is not readable: ${SCRIPT_PATH}"
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
find_cmd() {
#
# This function performs a search of the BINPATHS directories
# looking for the requested command. The full pathname is
# returned if the command is found.
#
# If a full pathname is provided then we simply check that
# it is executable.
#
CMD=$1
test -z "${CMD}" && return
if [ -n "`echo ${CMD} | grep '/'`" ]; then
test -f "${CMD}" -a -x "${CMD}" && echo "${CMD}"
else
for CMDDIR in ${BINPATHS}; do
if [ -f "${CMDDIR}/${CMD}" -a -x "${CMDDIR}/${CMD}" ]; then
echo "${CMDDIR}/${CMD}"
return
fi
done
fi
return
}
get_rootdir_option() {
RKHTMPVAR=`get_option single ROOTDIR` || exit 1
if [ -n "${RKHTMPVAR}" ]; then
echo "The ROOTDIR configuration option is now deprecated."
fi
return
}
get_existwl_option() {
#
# This function gets the configuration option used to whitelist
# files and directories from existing on the system. That is, they
# may or may not exist at the time of checking, but either way it
# will not cause an error.
#
# This option must be processed before other options because it will
# be used to whitelist some subsequent configuration option pathnames.
#
LEAVE=0
EXISTWL_OPT=`get_option newline-list EXISTWHITELIST` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${EXISTWL_OPT}" ]; then
EXISTWHITELIST=`expand_paths EXISTWL_OPT`
check_paths EXISTWHITELIST EXISTWHITELIST
test $ERRCODE -eq 1 && LEAVE=1
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_mailonwarn_option() {
#
# Get the option from the configuration file. If it is set,
# then we get the MAIL_CMD option as well.
#
LEAVE=0
MAILONWARNING=`get_option space-list MAIL-ON-WARNING` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${MAILONWARNING}" ]; then
MAIL_CMD=`get_option single MAIL_CMD` || exit 1
if [ $ERRCODE -eq 0 ]; then
test -z "${MAIL_CMD}" && MAIL_CMD="mail -s \"[rkhunter] Warnings found for \${HOST_NAME}\""
MCMD=`echo "${MAIL_CMD}" | cut -d' ' -f1`
check_paths MCMD MAIL_CMD "NOWILD EXIST NOBROKENLINK"
if [ $ERRCODE -eq 0 ]; then
#
# Check that the mail command is executable.
#
MC=`find_cmd ${MCMD}`
if [ -n "${MC}" ]; then
#
# We rebuild the command to use the full pathname.
#
MCMD=`echo "${MAIL_CMD}" | cut -d' ' -f2-`
if [ -z "${MCMD}" -o "${MCMD}" = "${MAIL_CMD}" ]; then
MAIL_CMD=$MC
else
MAIL_CMD="${MC} ${MCMD}"
fi
else
LEAVE=1
echo "Invalid MAIL_CMD configuration option: command is non-existent or not executable: ${MCMD}"
fi
else
LEAVE=1
fi
else
LEAVE=1
fi
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_webcmd_option() {
#
# Get the option from the configuration file. If it is set,
# then we set the RKHWEBCMD_OPTS option as well if necessary.
#
# For backwards compatability we will also check for WEBCMD.
#
LEAVE=0
RKHWEBCMD=`get_option single WEB_CMD` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -z "${RKHWEBCMD}" ]; then
RKHWEBCMD=`get_option single WEBCMD` || exit 1
test $ERRCODE -eq 1 && LEAVE=1
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 0 ]; then
if [ -n "${RKHWEBCMD}" ]; then
WCMD=`echo "${RKHWEBCMD}" | cut -d' ' -f1`
check_paths WCMD WEB_CMD "EXIST NOWILD NOBROKENLINK"
if [ $ERRCODE -eq 0 ]; then
#
# Check that the command is executable.
#
WC=`find_cmd ${WCMD}`
if [ -n "${WC}" ]; then
#
# We find if there any command options, and set
# the command to use the full pathname.
#
RKHWEBCMD_OPTS=`echo "${RKHWEBCMD}" | cut -d' ' -f2-`
test "${RKHWEBCMD_OPTS}" = "${RKHWEBCMD}" && RKHWEBCMD_OPTS=""
RKHWEBCMD="${WC}"
test -n "${BASENAME_CMD}" && RKHWEBCMD_BASE=`${BASENAME_CMD} "${WC}"` || RKHWEBCMD_BASE=`echo "${WC}" | sed -e 's:^.*/::'`
else
LEAVE=1
echo "Invalid WEB_CMD configuration option: command is non-existent or not executable: ${WCMD}"
fi
else
LEAVE=1
fi
fi
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_syslog_option() {
#
# First see if we want to use syslog or not from the command-line
# or configuration file.
#
LEAVE=0
if [ -n "${USE_SYSLOG}" ]; then
USE_SYSLOG=`echo "${USE_SYSLOG}" | tr -d '" ' | tr -d "'"`
if [ -z "${USE_SYSLOG}" ]; then
LEAVE=1
echo "Invalid '--syslog' option - no facility/priority names given."
fi
else
USE_SYSLOG=`get_option single USE_SYSLOG` || exit 1
test $ERRCODE -eq 1 && LEAVE=1
fi
#
# If we are to use syslog, then get the facility and priority levels.
# Additionally, test that they are valid.
#
if [ $LEAVE -eq 0 ]; then
if [ -n "${USE_SYSLOG}" ]; then
USE_SYSLOG=`echo "${USE_SYSLOG}" | tr '[:upper:]' '[:lower:]'`
if [ "${USE_SYSLOG}" = "none" ]; then
# The value of 'none' will be processed later on.
:
elif [ -z "`echo \"${USE_SYSLOG}\" | grep '^[a-z][a-z0-7]*\.[a-z][a-z]*$'`" ]; then
LEAVE=1
echo "Invalid syslog facility/priority value: ${USE_SYSLOG}"
fi
if [ $LEAVE -eq 0 -a "${USE_SYSLOG}" != "none" ]; then
FOUND=0
SYSLOG_F=`echo "${USE_SYSLOG}" | cut -d. -f1`
SYSLOG_P=`echo "${USE_SYSLOG}" | cut -d. -f2`
for RKHTMPVAR in auth authpriv cron daemon kern user local0 local1 local2 local3 local4 local5 local6 local7; do
if [ "${SYSLOG_F}" = "${RKHTMPVAR}" ]; then
FOUND=1
break
fi
done
if [ $FOUND -eq 0 ]; then
LEAVE=1
echo "Invalid syslog facility name: ${SYSLOG_F}"
fi
FOUND=0
for RKHTMPVAR in debug info notice warning err crit alert emerg; do
if [ "${SYSLOG_P}" = "${RKHTMPVAR}" ]; then
FOUND=1
break
fi
done
if [ $FOUND -eq 0 ]; then
LEAVE=1
echo "Invalid syslog priority name: ${SYSLOG_P}"
fi
fi
fi
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_ssh_options() {
#
# We check some SSH options in this function. They can only
# be set in the configuration file.
#
#
# See if the ALLOW_SSH_ROOT_USER option is specified in the
# configuration file. The value should match what has been set
# in the SSH configuration file for the PermitRootLogin option.
# As such it's value is not just zero or one.
#
LEAVE=0
ALLOW_SSH_ROOT_USER=`get_option single ALLOW_SSH_ROOT_USER` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${ALLOW_SSH_ROOT_USER}" ]; then
ALLOW_SSH_ROOT_USER=`echo "${ALLOW_SSH_ROOT_USER}" | tr '[:upper:]' '[:lower:]'`
else
#
# By default SSH tends to allow root access. However, we
# do not. By setting this option to 'no', the user will
# receive a warning unless they set the options the same.
#
ALLOW_SSH_ROOT_USER="no"
fi
else
LEAVE=1
fi
#
# See if the ALLOW_SSH_PROT_V1 option is specified in the
# configuration file.
#
ALLOW_SSH_PROT_V1=`get_option single ALLOW_SSH_PROT_V1` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${ALLOW_SSH_PROT_V1}" ]; then
check_is_digit ALLOW_SSH_PROT_V1 ALLOW_SSH_PROT_V1 2
test $ERRCODE -eq 1 && LEAVE=1
else
ALLOW_SSH_PROT_V1=0
fi
else
LEAVE=1
fi
#
# See if the directory of the SSH configuration file has been set.
#
SSH_CONFIG_DIR=`get_option single SSH_CONFIG_DIR` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${SSH_CONFIG_DIR}" ]; then
check_paths SSH_CONFIG_DIR SSH_CONFIG_DIR "EXIST NOWILD NOBROKENLINK"
if [ $ERRCODE -eq 0 ]; then
if [ ! -r "${SSH_CONFIG_DIR}" ]; then
LEAVE=1
echo "The SSH configuration file directory is not readable: ${SSH_CONFIG_DIR}"
fi
else
LEAVE=1
fi
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_syslog_config_options() {
#
# We check some syslog configuration options in this function.
# They can only be set in the configuration file.
#
#
# See if the ALLOW_SYSLOG_REMOTE_LOGGING option is specified
# in the configuration file.
#
LEAVE=0
ALLOW_SYSLOG_REMOTE_LOGGING=`get_option single ALLOW_SYSLOG_REMOTE_LOGGING` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${ALLOW_SYSLOG_REMOTE_LOGGING}" ]; then
check_is_digit ALLOW_SYSLOG_REMOTE_LOGGING
test $ERRCODE -eq 1 && LEAVE=1
else
ALLOW_SYSLOG_REMOTE_LOGGING=0
fi
else
LEAVE=1
fi
#
# See if the pathname to the syslog configuration file has been set.
#
SYSLOG_CONFIG_FILE=`get_option space-list SYSLOG_CONFIG_FILE` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${SYSLOG_CONFIG_FILE}" ]; then
if [ -n "`echo \"${SYSLOG_CONFIG_FILE}\" | grep -i '^none$'`" ]; then
SYSLOG_CONFIG_FILE="NONE"
else
check_paths SYSLOG_CONFIG_FILE SYSLOG_CONFIG_FILE "EXIST NOWILD NOBROKENLINK"
test $ERRCODE -eq 1 && LEAVE=1
fi
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_auto_x_option() {
#
# For the second colour set we first see if the auto X detect option
# has been set. If it is set, and X is in use, then the second colour
# set is used. If X is not in use, or the auto detect option is not
# set, then we only use the second colour set if the command-line
# option is used or it is configured in the configuration file.
#
LEAVE=0
if [ $AUTO_X_OPT -eq 0 ]; then
AUTO_X_DTCT=`get_option single AUTO_X_DETECT` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${AUTO_X_DTCT}" ]; then
check_is_digit AUTO_X_DTCT AUTO_X_DETECT
test $ERRCODE -eq 1 && LEAVE=1
else
AUTO_X_DTCT=0
fi
else
LEAVE=1
fi
fi
if [ $AUTO_X_DTCT -eq 1 -a -n "$DISPLAY" ]; then
CLRSET2=1
fi
if [ $CLRSET2 -eq 0 ]; then
CLRSET2=`get_option single COLOR_SET2` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${CLRSET2}" ]; then
check_is_digit CLRSET2 COLOR_SET2
test $ERRCODE -eq 1 && LEAVE=1
else
CLRSET2=0
fi
else
LEAVE=1
fi
fi
#
# Finally, we get the option to see if whitelisted
# results are to be shown as white rather than green.
#
WLIST_IS_WHITE=`get_option single WHITELISTED_IS_WHITE` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${WLIST_IS_WHITE}" ]; then
check_is_digit WLIST_IS_WHITE WHITELISTED_IS_WHITE
test $ERRCODE -eq 1 && LEAVE=1
else
WLIST_IS_WHITE=0
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_locking_options() {
#
# This function gets the configuration options to see if locking
# should be used when RKH is run. The mechanism for locking uses
# a simple timer, and will display some basic messages while RKH
# is trying to get the lock.
#
# All of these options can only be set in the configuration file.
#
LEAVE=0
USE_LOCKING=`get_option single USE_LOCKING` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${USE_LOCKING}" ]; then
check_is_digit USE_LOCKING
test $ERRCODE -eq 1 && LEAVE=1
else
USE_LOCKING=0
fi
else
LEAVE=1
fi
#
# Now get the lock timeout value. This must be a positive integer.
# The default value is 300 seconds (5 minutes).
#
LOCK_TIMEOUT=`get_option single LOCK_TIMEOUT` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${LOCK_TIMEOUT}" ]; then
check_is_digit LOCK_TIMEOUT LOCK_TIMEOUT ANY1
test $ERRCODE -eq 1 && LEAVE=1
else
LOCK_TIMEOUT=300
fi
else
LEAVE=1
fi
#
# Finally, we get the option to see if any lock messages should
# be shown or not. If the user has used the '--quiet' option,
# then we cannot display the lock messages. Otherwise, these are
# only shown on the screen, and not logged anywhere. The default
# is to show the messages.
#
if [ $QUIET -eq 0 ]; then
SHOW_LOCK_MSGS=`get_option single SHOW_LOCK_MSGS` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${SHOW_LOCK_MSGS}" ]; then
check_is_digit SHOW_LOCK_MSGS
test $ERRCODE -eq 1 && LEAVE=1
else
SHOW_LOCK_MSGS=1
fi
else
LEAVE=1
fi
else
SHOW_LOCK_MSGS=0
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
sort_test_lists() {
#
# This function is used to sort the list of test names for
# enabled and disabled tests. The first parameter determines
# which list is to be sorted:
#
# 1: enabled tests
# 2: disabled tests
#
RKHTMPVAR=$1
test $RKHTMPVAR -eq 1 && ENABLE_TESTS=`echo ${ENABLE_TESTS} | tr ' ' '\n' | sort | uniq`
test $RKHTMPVAR -eq 2 && DISABLE_TESTS=`echo ${DISABLE_TESTS} | tr ' ' '\n' | sort | uniq`
ENABLE_TESTS=`echo ${ENABLE_TESTS}`
DISABLE_TESTS=`echo ${DISABLE_TESTS}`
#
# Finally, test to see if the current lists are the same.
#
if [ "${ENABLE_TESTS}" = "${DISABLE_TESTS}" ]; then
test $ENDIS_OPT -eq 0 && RKHTMPVAR=" configured" || RKHTMPVAR=""
echo "The${RKHTMPVAR} enabled and disabled tests are the same."
if [ $ENDIS_OPT -eq 1 -o $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
check_test_options() {
#
# This function is called after we have obtained the enabled and
# disabled test names. It will check that the test names are valid,
# and remove any enabled test names from the disabled list.
#
#
# First we loop through the enabled and disabled test names, and see
# if the special names of 'all' or 'none' are used. If so, then these
# will either override all the other test names in the list, or be an
# error. We also look for any invalid test names.
#
SEEN=0
LEAVE=0
RKHTMPVAR=" `echo ${KNOWN_TESTS}` "
for TEST_NAME in ${ENABLE_TESTS}; do
if [ "${TEST_NAME}" = "all" ]; then
SEEN=1
elif [ "${TEST_NAME}" = "none" ]; then
if [ $ENABLE_OPT -eq 1 ]; then
LEAVE=1
echo "'none' cannot be used in the enabled test list."
else
LEAVE=1
echo "'none' cannot be used in the configured enabled test list."
fi
elif [ -z "`echo \"${RKHTMPVAR}\" | grep \" ${TEST_NAME} \"`" ]; then
LEAVE=1
echo "Unknown enabled test name given: ${TEST_NAME}"
fi
done
test $SEEN -eq 1 && ENABLE_TESTS="all"
#
# For the disabled tests we need to loop through the
# command-line and configuration file test names separately.
#
SEEN=0
for TEST_NAME in ${CL_DISABLE_TESTS}; do
if [ "${TEST_NAME}" = "none" ]; then
SEEN=1
elif [ "${TEST_NAME}" = "all" ]; then
LEAVE=1
echo "'all' cannot be used in the disabled test list."
elif [ -z "`echo \"${RKHTMPVAR}\" | grep \" ${TEST_NAME} \"`" ]; then
LEAVE=1
echo "Unknown disabled test name given: ${TEST_NAME}"
fi
done
if [ $USECF -eq 1 ]; then
for TEST_NAME in ${CONFIG_DISABLE_TESTS}; do
if [ "${TEST_NAME}" = "none" ]; then
SEEN=1
elif [ "${TEST_NAME}" = "all" ]; then
LEAVE=1
echo "'all' cannot be used in the configured disabled test list."
elif [ -z "`echo \"${RKHTMPVAR}\" | grep \" ${TEST_NAME} \"`" ]; then
LEAVE=1
echo "Unknown disabled test name in the configuration file: ${TEST_NAME}"
fi
done
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
return
fi
fi
test $SEEN -eq 1 && DISABLE_TESTS="none"
#
# If we are to run all the tests, then we use whatever
# disabled tests the user has given us.
#
test "${ENABLE_TESTS}" = "all" && return
#
# Now we can loop through the command-line enabled specific test names,
# and remove them from the disabled list. We need to do this otherwise
# the tests would not run. We don't bother to do this for the configuration
# file enabled tests because we assume the user has already checked this.
#
if [ $ENABLE_OPT -eq 1 -a "${DISABLE_TESTS}" != "none" ]; then
#
# First get a list of just the group test names.
#
GROUP_TEST_NAMES=""
for RKHTMPVAR in ${GROUPED_TESTS}; do
GROUP_TEST_NAMES="${GROUP_TEST_NAMES} `echo "${RKHTMPVAR}" | cut -d: -f1`"
done
GROUP_TEST_NAMES=" `echo ${GROUP_TEST_NAMES}` "
#
# Now loop through the specific test names.
#
DISABLE_TESTS=" ${DISABLE_TESTS} "
for TEST_NAME in ${ENABLE_TESTS}; do
if [ -z "`echo \"${GROUP_TEST_NAMES}\" | grep \" ${TEST_NAME} \"`" ]; then
if [ -n "`echo \"${DISABLE_TESTS}\" | grep \" ${TEST_NAME} \"`" ]; then
DISABLE_TESTS=`echo "${DISABLE_TESTS}" | sed -e "s/ ${TEST_NAME} / /"`
fi
fi
done
DISABLE_TESTS=`echo ${DISABLE_TESTS}`
if [ -z "${DISABLE_TESTS}" ]; then
DISABLE_TESTS="none"
else
sort_test_lists 2
fi
fi
#
# Next we expand the enabled test group names. This will leave us
# with a list of specific test names, and their associated group test
# names. We also need to check if a given test name is part of a
# group. If it is, then we must add the group name.
#
for TEST_NAME in ${ENABLE_TESTS}; do
for RKHTMPVAR in ${GROUPED_TESTS}; do
GROUP_NAME=`echo "${RKHTMPVAR}" | cut -d: -f1`
if [ -n "`echo \"${RKHTMPVAR}\" | grep ':'`" ]; then
GROUP_TESTS=`echo "${RKHTMPVAR}" | cut -d: -f2-`
else
GROUP_TESTS=""
fi
if [ "${TEST_NAME}" = "${GROUP_NAME}" ]; then
ENABLE_TESTS="${ENABLE_TESTS} `echo \"${GROUP_TESTS}\" | tr ':' ' '`"
break
elif [ -z "${GROUP_TESTS}" ]; then
continue
elif [ -n "`echo \":${GROUP_TESTS}:\" | grep \":${TEST_NAME}:\"`" ]; then
ENABLE_TESTS="${ENABLE_TESTS} ${GROUP_NAME}"
fi
done
done
ENABLE_TESTS=`echo ${ENABLE_TESTS}`
sort_test_lists 1
#
# Finally, we temporarily expand the disabled test names and temporarily
# remove any matching names from the enabled test list. Although these
# tests would never run, we need to do this in order to see if the user
# has given us an invalid list of tests.
#
if [ "${DISABLE_TESTS}" != "none" ]; then
TEMP_EN_TESTS="${ENABLE_TESTS}"
TEMP_DIS_TESTS="${DISABLE_TESTS}"
for TEST_NAME in ${TEMP_DIS_TESTS}; do
for RKHTMPVAR in ${GROUPED_TESTS}; do
GROUP_NAME=`echo "${RKHTMPVAR}" | cut -d: -f1`
if [ -n "`echo \"${RKHTMPVAR}\" | grep ':'`" ]; then
GROUP_TESTS=`echo "${RKHTMPVAR}" | cut -d: -f2-`
else
GROUP_TESTS=""
fi
if [ "${TEST_NAME}" = "${GROUP_NAME}" ]; then
TEMP_DIS_TESTS="${TEMP_DIS_TESTS} `echo \"${GROUP_TESTS}\" | tr ':' ' '`"
break
elif [ -z "${GROUP_TESTS}" ]; then
continue
elif [ -n "`echo \":${GROUP_TESTS}:\" | grep \":${TEST_NAME}:\"`" ]; then
TEMP_DIS_TESTS="${TEMP_DIS_TESTS} ${GROUP_NAME}"
fi
done
done
TEMP_DIS_TESTS=" `echo ${TEMP_DIS_TESTS}` "
#
# Now loop through the enabled tests and remove any matches.
#
for TEST_NAME in ${TEMP_EN_TESTS}; do
if [ -n "`echo \"${TEMP_DIS_TESTS}\" | grep \" ${TEST_NAME} \"`" ]; then
TEMP_EN_TESTS=`echo " ${TEMP_EN_TESTS} " | sed -e "s/ ${TEST_NAME} / /"`
fi
done
TEMP_EN_TESTS=`echo ${TEMP_EN_TESTS}`
if [ -z "${TEMP_EN_TESTS}" ]; then
LEAVE=0
if [ $ENABLE_OPT -eq 1 ]; then
LEAVE=1
echo "Invalid enabled test list - no tests to run."
else
LEAVE=1
echo "Invalid configured enabled test list - no tests to run."
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
fi
fi
return
}
get_enable_option() {
#
# This function gets the enabled test names from the command-line
# or the configuration file as required. The test names will be
# checked later on. By default all tests are enabled.
#
#
# Get the command-line test names. These override
# the configuration file enabled test names.
#
LEAVE=0
if [ $ENABLE_OPT -eq 1 ]; then
ENABLE_TESTS=`echo "${CL_ENABLE_TESTS}" | tr -d '"' | tr -d "'" | tr ',' ' '`
ENABLE_TESTS=`echo ${ENABLE_TESTS}`
if [ -z "${ENABLE_TESTS}" ]; then
LEAVE=1
echo "Invalid '--enable' option - no test names given."
else
ENABLE_TESTS=`echo "${ENABLE_TESTS}" | tr '[:upper:]' '[:lower:]'`
fi
#
# We do a simple test here to see if just one test was enabled.
# If it was then we skip the key press feature since it is most
# likely that the user doesn't want that. The test name cannot be
# 'all'.
#
if [ "${ENABLE_TESTS}" != "all" -a -z "`echo \"${ENABLE_TESTS}\" | grep ' '`" ]; then
SKIP_KEY_PRESS=1
fi
else
#
# We get the configuration file entries by default.
#
ENABLE_TESTS=`get_option space-list ENABLE_TESTS` || exit 1
if [ $ERRCODE -eq 0 ]; then
ENABLE_TESTS=`echo "${ENABLE_TESTS}" | tr '[:upper:]' '[:lower:]'`
# The system default.
test -z "${ENABLE_TESTS}" && ENABLE_TESTS="all"
else
LEAVE=1
fi
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_disable_option() {
#
# This function gets the disabled test names from the command-line
# and the configuration file if required. The test names will be
# checked later on. By default no tests are disabled.
#
# Note: disabled tests are always compared against the list
# of enabled tests. Hence, if we used
# 'rkhunter -c --enable system_commands --disable apps'
# then only the system command tests are run. Any other test is
# not run because it is not in the '--enable' list. As such
# the '--disable' option in the example above is not necessary.
#
#
# Get the command-line test names.
#
LEAVE=0
if [ -n "${CL_DISABLE_TESTS}" ]; then
CL_DISABLE_TESTS=`echo "${CL_DISABLE_TESTS}" | tr -d '"' | tr -d "'" | tr ',' ' '`
CL_DISABLE_TESTS=`echo ${CL_DISABLE_TESTS}`
if [ -z "${CL_DISABLE_TESTS}" ]; then
LEAVE=1
echo "Invalid '--disable' option - no test names given."
fi
fi
#
# Get the configuration file test names
# unless specifically requested not to do so.
#
if [ $USECF -eq 1 ]; then
CONFIG_DISABLE_TESTS=`get_option space-list DISABLE_TESTS` || exit 1
test $ERRCODE -eq 1 && LEAVE=1
fi
if [ $LEAVE -eq 0 ]; then
DISABLE_TESTS="${CL_DISABLE_TESTS} ${CONFIG_DISABLE_TESTS}"
DISABLE_TESTS=`echo ${DISABLE_TESTS}`
if [ -z "${DISABLE_TESTS}" ]; then
# The system default.
DISABLE_TESTS="none"
else
DISABLE_TESTS=`echo "${DISABLE_TESTS}" | tr '[:upper:]' '[:lower:]'`
fi
else
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_xinetd_option() {
#
# This function obtains the inetd and xinetd configuration
# file pathnames from the config file. It also get the
# whitelisted services.
#
LEAVE=0
FNAME=`get_option single INETD_CONF_PATH` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${FNAME}" ]; then
check_paths FNAME INETD_CONF_PATH "NOWILD EXIST NOBROKENLINK"
if [ $ERRCODE -eq 0 ]; then
INETD_CONF_PATH="${FNAME}"
else
LEAVE=1
fi
fi
else
LEAVE=1
fi
INETDALLOWEDSVCS=`get_option space-list INETD_ALLOWED_SVC` || exit 1
test $ERRCODE -eq 1 && LEAVE=1
#
# Now do the same for xinetd.
#
FNAME=`get_option single XINETD_CONF_PATH` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${FNAME}" ]; then
check_paths FNAME XINETD_CONF_PATH "EXIST NOWILD NOBROKENLINK"
if [ $ERRCODE -eq 0 ]; then
XINETD_CONF_PATH="${FNAME}"
else
LEAVE=1
fi
fi
else
LEAVE=1
fi
XINETDALLOWEDSVCS=`get_option space-list XINETD_ALLOWED_SVC` || exit 1
test $ERRCODE -eq 1 && LEAVE=1
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_port_options() {
#
# This function will get the various PORT configuration options, and
# build up PORT_WHITELIST as a newline-separated list.
#
# First get the PORT_WHITELIST option from the configuration file.
#
LEAVE=0
PORT_WHITELIST=""
RKHTMPVAR=`get_option space-list PORT_WHITELIST` || exit 1
if [ $ERRCODE -eq 1 ]; then
LEAVE=1
else
if [ -n "${RKHTMPVAR}" ]; then
#
# Loop through the list checking that it all looks okay.
#
for RKHTMPVAR2 in ${RKHTMPVAR}; do
if [ -n "`echo \"${RKHTMPVAR2}\" | egrep -i '^(TCP|UDP):[1-9][0-9]*$'`" ]; then
PROTO=`echo ${RKHTMPVAR2} | cut -d: -f1 | tr '[:lower:]' '[:upper:]'`
PORT=`echo ${RKHTMPVAR2} | cut -d: -f2`
if [ $PORT -gt 65535 ]; then
LEAVE=1
echo "Invalid PORT_WHITELIST configuration option - invalid port specified: `name2text \"${RKHTMPVAR2}\"`"
fi
PORT_WHITELIST="${PORT_WHITELIST}
${PROTO}:${PORT}"
elif [ "${RKHTMPVAR2}" = "*" ]; then
if [ -n "${LSOF_CMD}" ]; then
PORT_WHITELIST_ALL_TRUSTED=1
else
LEAVE=1
echo "Invalid PORT_WHITELIST configuration option - '*' requires the 'lsof' command."
fi
else
LEAVE=1
echo "Invalid entry specified in PORT_WHITELIST configuration option: `name2text \"${RKHTMPVAR2}\"`"
fi
done
fi
fi
#
# Now get the PORT_PATH_WHITELIST option from the configuration file.
#
RKHTMPVAR=`get_option newline-list PORT_PATH_WHITELIST` || exit 1
if [ $ERRCODE -eq 1 ]; then
LEAVE=1
elif [ -z "${LSOF_CMD}" ]; then
if [ -n "${RKHTMPVAR}" ]; then
LEAVE=1
echo "Invalid PORT_PATH_WHITELIST configuration option - the 'lsof' command is required."
fi
elif [ -n "${RKHTMPVAR}" ]; then
#
# Loop through the list checking that it all looks okay.
#
IFS=$IFSNL
for RKHTMPVAR2 in ${RKHTMPVAR}; do
if [ -n "`echo \"${RKHTMPVAR2}\" | grep '^/'`" ]; then
PORT=0
FNAME=""
PROTO=""
# Dig out the protocol and port number, if present.
if [ -n "`echo \"${RKHTMPVAR2}\" | egrep -i '.:(TCP|UDP):[1-9][0-9]*$'`" ]; then
PROTO=`echo "${RKHTMPVAR2}" | sed -e 's/^.*:\([a-zA-Z]*\):[1-9][0-9]*$/\1/'`
PORT=`echo "${RKHTMPVAR2}" | sed -e 's/^.*:\([1-9][0-9]*\)$/\1/'`
if [ $PORT -gt 65535 ]; then
LEAVE=1
echo "Invalid PORT_PATH_WHITELIST configuration option - invalid port specified: `name2text \"${RKHTMPVAR2}\"`"
fi
PROTO=`echo ${PROTO} | tr '[:lower:]' '[:upper:]'`
fi
# Dig out the pathname.
if [ $PORT -gt 0 ]; then
FNAME=`echo "${RKHTMPVAR2}" | sed -e 's/^\(.*\):[a-zA-Z]*:[1-9][0-9]*$/\1/'`
else
FNAME="${RKHTMPVAR2}"
fi
IFS=$RKHIFS
check_paths FNAME PORT_PATH_WHITELIST "EXIST NOWILD NOBROKENLINK"
IFS=$IFSNL
if [ $ERRCODE -eq 1 ]; then
LEAVE=1
else
if [ $PORT -gt 0 ]; then
PORT_WHITELIST="${PORT_WHITELIST}
${FNAME}:${PROTO}:${PORT}"
else
PORT_WHITELIST="${PORT_WHITELIST}
${FNAME}"
fi
fi
else
LEAVE=1
echo "Invalid entry specified in PORT_PATH_WHITELIST configuration option: `name2text \"${RKHTMPVAR2}\"`"
fi
done
IFS=$RKHIFS
fi
if [ -n "${PORT_WHITELIST}" ]; then
PORT_WHITELIST=`echo "${PORT_WHITELIST}" | sed -e '/^$/d'`
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_groups_accounts_options() {
#
# Get the location of the password/shadow file. We also cater
# for cases such as BSD systems and users of TCB shadow files.
# If the shadow file itself does not exist, then we look in
# the password file itself to see if it contains the passwords.
#
LEAVE=0
SHADOW_FILE=`get_option single PASSWORD_FILE` || exit 1
test $ERRCODE -eq 1 && LEAVE=1
if [ -n "${SHADOW_FILE}" ]; then
check_paths SHADOW_FILE PASSWORD_FILE "EXIST NOWILD NOBROKENLINK"
if [ $ERRCODE -eq 0 ]; then
if [ -s "${SHADOW_FILE}" ]; then
SHADOW_FILE="${SHADOW_FILE}"
else
SHADOW_FILE=""
fi
else
LEAVE=1
fi
elif [ -s "/etc/shadow" ]; then
SHADOW_FILE="/etc/shadow"
elif [ \( $BSDOS -eq 1 -o $MACOSX -eq 1 \) -a -s "/etc/master.passwd" ]; then
SHADOW_FILE="/etc/master.passwd"
elif [ -f "/etc/tcb/root/shadow" ]; then
HAVE_TCB_SHADOW=1
elif [ -s "/etc/passwd" ]; then
#
# If the passwords are stored in the passwd file, then
# it should contain at least 3 non-colon characters in the
# second field. Checking for 3 characters allows for normal
# shadow entries such as 'x', '!!' or '*'. It is assumed
# that at least one account will have a password.
#
if [ -n "`grep '^[^:]*:[^:][^:][^:]' /etc/passwd`" ]; then
SHADOW_FILE="/etc/passwd"
fi
fi
#
# Now get the passwordless account whitelist option.
#
PWD_WHITELIST=`get_option space-list PWDLESS_ACCOUNTS` || exit 1
if [ $ERRCODE -eq 0 ]; then
test -n "${PWD_WHITELIST}" && PWD_WHITELIST=" ${PWD_WHITELIST} "
else
LEAVE=1
fi
#
# Next get any root-equivalent whitelisted account names.
#
UID0_WHITELIST=`get_option space-list UID0_ACCOUNTS` || exit 1
if [ $ERRCODE -eq 0 ]; then
# By default we allow the root account.
UID0_WHITELIST=" root ${UID0_WHITELIST} "
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
test_epoch_cmd() {
#
# This function simply checks if the supplied command
# can process epoch second times. We do this by using
# the '%s' formatting option, and the 'seconds ago'
# time format. If the command understands both of these
# then we can use it for the epoch date.
#
RKHTMPVAR=$1
if [ -n "`${RKHTMPVAR} --date '5 seconds ago' '+%s' 2>/dev/null | grep '^[0-9][0-9]*$'`" ]; then
EPOCH_DATE_CMD="${RKHTMPVAR}"
fi
return
}
get_epoch_date_cmd_option() {
#
# Get the option from the configuration file, or work out
# if the 'date' command is suitable.
#
LEAVE=0
EPOCH_DATE_CMD=`get_option single EPOCH_DATE_CMD` || exit 1
if [ $ERRCODE -eq 0 ]; then
#
# Check the type of config file option we have. They user may have
# specified a command to use or 'NONE', in which case we return.
# If they specified 'PERL' then check we have a 'perl' command,
# and then return.
#
if [ "${EPOCH_DATE_CMD}" = "PERL" ]; then
EPOCH_DATE_CMD=""
test -z "${PERL_CMD}" && EPOCH_DATE_CMD="NONE"
return
elif [ "${EPOCH_DATE_CMD}" = "NONE" ]; then
return
elif [ -n "${EPOCH_DATE_CMD}" ]; then
RKHTMPVAR=`echo "${EPOCH_DATE_CMD}" | cut -d' ' -f1`
check_paths RKHTMPVAR EPOCH_DATE_CMD "EXIST NOWILD NOBROKENLINK"
#
# Check that the command exists and is executable.
#
if [ $ERRCODE -eq 0 ]; then
FNAME=`find_cmd ${RKHTMPVAR}`
if [ -n "${FNAME}" ]; then
RKHTMPVAR2=`echo "${EPOCH_DATE_CMD}" | cut -d' ' -f2-`
if [ -z "${RKHTMPVAR2}" -o "${RKHTMPVAR2}" = "${EPOCH_DATE_CMD}" ]; then
EPOCH_DATE_CMD="${FNAME}"
else
EPOCH_DATE_CMD="${FNAME} ${RKHTMPVAR2}"
fi
else
EPOCH_DATE_CMD="NONE"
fi
else
LEAVE=1
fi
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 0 ]; then
#
# Now we test if the 'date' command supports processing epoch seconds.
#
test_epoch_cmd "date"
test -n "${EPOCH_DATE_CMD}" && return
#
# For SunOS systems we need to check some other 'date' commands.
#
if [ $SUNOS -eq 1 ]; then
for RKHTMPVAR2 in `find_cmd gdate` /opt/sfw/bin/date; do
test_epoch_cmd "${RKHTMPVAR2}"
test -n "${EPOCH_DATE_CMD}" && break
done
fi
else
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_phalanx2_option() {
#
# This is a specific function to get the PHALANX2_DIRTEST
# option. It must be a digit, and can only be tested for
# on Linux systems.
#
test $LINUXOS -eq 0 && return
LEAVE=0
ROOTKIT_PHALANX2_DIRTESTVAL=`get_option single PHALANX2_DIRTEST` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${ROOTKIT_PHALANX2_DIRTESTVAL}" ]; then
check_is_digit ROOTKIT_PHALANX2_DIRTESTVAL
test $ERRCODE -eq 1 && LEAVE=1
else
ROOTKIT_PHALANX2_DIRTESTVAL=0
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_dev_options() {
#
# This function processes the ALLOWDEVFILE option which is
# used to whitelist files allowed in the '/dev' directory.
#
LEAVE=0
ALLOWDEVFILES=""
ALLOWDEVFILE_OPT=`get_option newline-list ALLOWDEVFILE` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${ALLOWDEVFILE_OPT}" ]; then
# Note that we do not get the expanded list of pathnames at
# this point. That will be done when the test actually runs.
ALLOWDEVFILES=${ALLOWDEVFILE_OPT}
check_paths ALLOWDEVFILES ALLOWDEVFILE
test $ERRCODE -eq 1 && LEAVE=1
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_hidden_options() {
#
# This function processes the ALLOWHIDDENFILE and ALLOWHIDDENDIR
# options which are used to whitelist hidden files and directories.
#
LEAVE=0
ALLOWHIDDENFILES=""
ALLOWHIDDENFILE_OPT=`get_option newline-list ALLOWHIDDENFILE` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${ALLOWHIDDENFILE_OPT}" ]; then
# Note that we do not get the expanded list of pathnames at
# this point. That will be done when the test actually runs.
ALLOWHIDDENFILES=${ALLOWHIDDENFILE_OPT}
check_paths ALLOWHIDDENFILES ALLOWHIDDENFILE
test $ERRCODE -eq 1 && LEAVE=1
fi
else
LEAVE=1
fi
ALLOWHIDDENDIRS=""
ALLOWHIDDENDIR_OPT=`get_option newline-list ALLOWHIDDENDIR` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${ALLOWHIDDENDIR_OPT}" ]; then
ALLOWHIDDENDIRS=${ALLOWHIDDENDIR_OPT}
check_paths ALLOWHIDDENDIRS ALLOWHIDDENDIR
test $ERRCODE -eq 1 && LEAVE=1
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_missing_file_options() {
#
# This function processes the options used to detect missing or
# empty files. Note that we do not use the 'EXIST' option for
# 'check_paths' despite the fact that the files should exist.
# However, if they are missing then that is exactly what we want
# the test to report.
#
LEAVE=0
LOGFILE_MISSING=`get_option space-list MISSING_LOGFILES` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${LOGFILE_MISSING}" ]; then
check_paths LOGFILE_MISSING MISSING_LOGFILES "NOWILD"
test $ERRCODE -eq 1 && LEAVE=1
fi
else
LEAVE=1
fi
LOGFILE_EMPTY=`get_option space-list EMPTY_LOGFILES` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${LOGFILE_EMPTY}" ]; then
check_paths LOGFILE_EMPTY EMPTY_LOGFILES "NOWILD"
test $ERRCODE -eq 1 && LEAVE=1
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_unhide_options() {
#
# This function processes the configuration options used
# by the unhide commands in the 'hidden_procs' test.
#
LEAVE=0
UNHIDE_TESTS=`get_option space-list UNHIDE_TESTS` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -z "${UNHIDE_TESTS}" ]; then
UNHIDE_TESTS="sys"
elif [ -z "`echo \" ${UNHIDE_TESTS}\" | grep ' [a-zA-Z]'`" ]; then
LEAVE=1
echo "Invalid UNHIDE_TESTS configuration option - no tests specified: ${UNHIDE_TESTS}"
fi
else
LEAVE=1
fi
UNHIDETCP_OPTS=""
RKHTMPVAR=`get_option space-list UNHIDETCP_OPTS` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${RKHTMPVAR}" ]; then
for RKHTMPVAR2 in ${RKHTMPVAR}; do
#
# For options we need to add a space to the variable
# to avoid problems with the 'echo' command.
#
if [ -z "`echo \"${RKHTMPVAR2} \" | grep '^-'`" ]; then
# Options must begin with a '-'.
LEAVE=1
echo "Invalid UNHIDETCP_OPTS configuration option - not a valid option: ${RKHTMPVAR}"
elif [ "${RKHTMPVAR2}" = "-V" -o "${RKHTMPVAR2}" = "-h" ]; then
# Ignore obvious invalid options.
continue
else
UNHIDETCP_OPTS="${UNHIDETCP_OPTS} ${RKHTMPVAR2}"
fi
done
# Add a space to avoid the 'echo' problem with options.
UNHIDETCP_OPTS=`echo "${UNHIDETCP_OPTS} " | sed -e 's/^ *//'`
fi
else
LEAVE=1
fi
NOUNHIDE=`get_option single DISABLE_UNHIDE` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${NOUNHIDE}" ]; then
check_is_digit NOUNHIDE DISABLE_UNHIDE 2
test $ERRCODE -eq 1 && LEAVE=1
else
NOUNHIDE=0
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_process_options() {
#
# Get any options used by checks on processes.
#
#
# We do no testing of this option because if the user gets it wrong,
# then the processes will show up as warnings. The user should (!)
# then check the configuration file to make sure it is correct.
#
LEAVE=0
ALLOWPROCDELFILES=`get_option newline-list ALLOWPROCDELFILE` || exit 1
test $ERRCODE -eq 1 && LEAVE=1
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_suspscan_options() {
#
# This function processes all the options
# required for the suspscan test.
#
LEAVE=0
SUSPSCAN_DFLT_TMP=0
SUSPSCAN_DFLT_DIRS=0
SUSPSCAN_DFLT_THRESH=0
SUSPSCAN_DFLT_MAXSIZE=0
#
# Get the directories to scan.
#
SUSPSCAN_DIRS=`get_option space-list SUSPSCAN_DIRS` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${SUSPSCAN_DIRS}" ]; then
check_paths SUSPSCAN_DIRS SUSPSCAN_DIRS "EXIST NOBROKENLINK NOWILD"
test $ERRCODE -eq 1 && LEAVE=1
else
SUSPSCAN_DFLT_DIRS=1
SUSPSCAN_DIRS="/tmp /var/tmp"
fi
else
LEAVE=1
fi
#
# Get the tempdir to use. It should be a /dev/shm type.
#
SUSPSCAN_TEMP=`get_option single SUSPSCAN_TEMP` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -z "${SUSPSCAN_TEMP}" ]; then
SUSPSCAN_DFLT_TMP=1
SUSPSCAN_TEMP="/dev/shm"
fi
check_paths SUSPSCAN_TEMP SUSPSCAN_TEMP "EXIST NOBROKENLINK NOWILD"
if [ $ERRCODE -eq 0 ]; then
if [ ! -w "${SUSPSCAN_TEMP}" ]; then
LEAVE=1
echo "The suspscan temporary directory is not writable: ${SUSPSCAN_TEMP}"
fi
else
LEAVE=1
fi
else
LEAVE=1
fi
#
# Get the maximum file size to handle, for example 1024000.
#
SUSPSCAN_MAXSIZE=`get_option single SUSPSCAN_MAXSIZE` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${SUSPSCAN_MAXSIZE}" ]; then
check_is_digit SUSPSCAN_MAXSIZE SUSPSCAN_MAXSIZE ANY1
test $ERRCODE -eq 1 && LEAVE=1
else
SUSPSCAN_DFLT_MAXSIZE=1
SUSPSCAN_MAXSIZE=1024000
fi
else
LEAVE=1
fi
#
# Get the score threshold, 200 seems sensible.
#
SUSPSCAN_THRESH=`get_option single SUSPSCAN_THRESH` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${SUSPSCAN_THRESH}" ]; then
check_is_digit SUSPSCAN_THRESH SUSPSCAN_THRESH ANY1
test $ERRCODE -eq 1 && LEAVE=1
else
SUSPSCAN_THRESH=200
SUSPSCAN_DFLT_THRESH=1
fi
else
LEAVE=1
fi
#
# Get the line threshold. This exists purely for performance reasons. 3000 seems sensible as
# Linux Kernel Modules don't exceed 2000 lines and for example most binaries in /bin don't exceed 3000 lines.
# Note this configuration option will remain unlisted in both the documentation and configuration file.
#
SUSPSCAN_LINETHRESH=`get_option single SUSPSCAN_LINETHRESH` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${SUSPSCAN_LINETHRESH}" ]; then
check_is_digit SUSPSCAN_LINETHRESH SUSPSCAN_LINETHRESH ANY1
test $ERRCODE -eq 1 && LEAVE=1
else
SUSPSCAN_LINETHRESH=3000
fi
else
LEAVE=1
fi
#
# Get the debug flag value (defaults to 0). Setting this to 1 will cause verbose messages to be displayed
# which will result in more warnings than you will want. Changing the SUSPSCAN_DEBUG default value implies
# that you know what you are doing and that you don't need help "fixing" things afterwards.
#
SUSPSCAN_DEBUG=`get_option single SUSPSCAN_DEBUG` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${SUSPSCAN_DEBUG}" ]; then
check_is_digit SUSPSCAN_DEBUG
test $ERRCODE -eq 1 && LEAVE=1
else
SUSPSCAN_DEBUG=0
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_if_prelinked() {
#
# A prelinked system is defined here as one which has a 'prelink'
# command, and the '/etc/prelink.cache' file exists.
#
if [ -f "/etc/prelink.cache" ]; then
#
# Check that we have a 'prelink' command. If it
# doesn't exist, then we cannot use prelinking.
#
PRELINK_CMD=`find_cmd prelink`
test -z "${PRELINK_CMD}" && return
#
# We test (twice) for the existence of Libsafe since this seems to
# riddle prelink test results with "dependency cycle" errors.
# Don't test for existence of /lib/libsafe since it may be
# installed elsewhere. If Libsafe is found, then we'll skip the
# file properties hash test.
#
LIBSAFE_TEST1=""
LIBSAFE_TEST2=""
if [ -f "/etc/ld.so.preload" ]; then
LIBSAFE_TEST1=`grep 'libsafe' /etc/ld.so.preload 2>&1`
fi
if [ -z "${LIBSAFE_TEST1}" ]; then
LIBSAFE_TEST1=`echo "$LD_PRELOAD" | grep 'libsafe' 2>&1`
fi
if [ -n "${LDD_CMD}" ]; then
if [ -f /lib/libdl.so.? ]; then
LIBSAFE_TEST2=`${LDD_CMD} /lib/libdl.so.? | grep 'libsafe' 2>&1`
fi
if [ -z "${LIBSAFE_TEST2}" -a -f /lib64/libdl.so.? ]; then
LIBSAFE_TEST2=`${LDD_CMD} /lib64/libdl.so.? | grep 'libsafe' 2>&1`
fi
fi
if [ -z "${LIBSAFE_TEST1}" -a -z "${LIBSAFE_TEST2}" ]; then
PRELINKED=1
#
# Only use 'runcon' if SELinux is enabled.
#
SESTATUS_CMD=`find_cmd sestatus`
if [ -n "${SESTATUS_CMD}" ]; then
if [ -n "`${SESTATUS_CMD} 2>/dev/null | grep ' status: *enabled$'`" ]; then
SELINUX_ENABLED=1
RUNCON_CMD=`find_cmd runcon`
test -n "${RUNCON_CMD}" && USE_RUNCON=1
fi
fi
elif [ -n "${LIBSAFE_TEST1}" -a -n "${LIBSAFE_TEST2}" ]; then
SKIP_HASH_MSG=2
fi
fi
return
}
get_md5_hash_function() {
#
# This is a short function to try and locate
# an MD5 hash function command.
#
if [ $PRELINKED -eq 1 ]; then
if [ $USE_RUNCON -eq 1 ]; then
echo "${RUNCON_CMD} -u root -- ${PRELINK_CMD} --verify --md5"
else
echo "${PRELINK_CMD} --verify --md5"
fi
else
HFUNC=`find_cmd md5sum`
test -z "${HFUNC}" && HFUNC=`find_cmd md5`
if [ -z "${HFUNC}" -a -n "${PERL_CMD}" ]; then
MOD_INSTALLED=`${PERL_CMD} "${SCRIPT_PATH}/check_modules.pl" Digest::MD5 2>/dev/null | grep 'Digest::MD5 installed'`
test -n "${MOD_INSTALLED}" && echo "${PERL_CMD} ${SCRIPT_PATH}/filehashsha.pl Digest::MD5 0"
else
echo "${HFUNC}"
fi
fi
return
}
get_hash_function() {
#
# Get the option from the configuration file, and do a simple
# check on whether it is empty or a space.
#
LEAVE=0
if [ $HASH_OPT -eq 1 ]; then
HASH_FUNC=`echo "${HASH_FUNC}" | tr -d '"' | tr -d "'" | tr -s ' ' ' '`
HASH_CMD=`echo "${HASH_FUNC}" | cut -d' ' -f1`
# Stop globbing from being expanded.
if [ -z "`echo \"${HASH_CMD}\" | grep '[][*?{}]'`" ]; then
HASH_FUNC=`echo ${HASH_FUNC}`
else
LEAVE=1
HASH_FUNC="NONE"
echo "Invalid '--hash' option: invalid pathname: ${HASH_CMD}"
fi
if [ -z "${HASH_FUNC}" ]; then
LEAVE=1
HASH_FUNC="NONE"
echo "Invalid '--hash' option: no hash function given."
fi
else
HASH_FUNC=`get_option single HASH_CMD` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -z "${HASH_FUNC}" ]; then
HASH_FUNC=`get_option single HASH_FUNC` || exit 1
test $ERRCODE -eq 1 && LEAVE=1
fi
else
LEAVE=1
fi
fi
#
# Test to ensure that globbing and other invalid
# pathnames have not been given.
#
if [ -n "${HASH_FUNC}" ]; then
HASH_CMD=`echo "${HASH_FUNC}" | cut -d' ' -f1`
check_paths HASH_CMD HASH_CMD "EXIST NOWILD NOBROKENLINK"
if [ $ERRCODE -eq 1 ]; then
LEAVE=1
HASH_FUNC="NONE"
fi
fi
if [ -n "`echo \"${HASH_FUNC}\" | egrep -i '^(MD5|SHA1|SHA224|SHA256|SHA384|SHA512|RIPEMD160|WHIRLPOOL|NONE)$'`" ]; then
HASH_FUNC=`echo "${HASH_FUNC}" | tr '[:lower:]' '[:upper:]'`
fi
#
# At this point we have either been given a specific hash function
# command, the reserved word 'NONE', one of the SHA or other functions,
# or nothing. For the SHA and MD5 reserved words we must find the SHA
# or MD5 command, or use the supplied perl scripts. For the RIPEMD160
# and WHIRLPOOL reserved words, we use the perl scripts.
#
SHA_SIZE=0
test -z "${HASH_FUNC}" && HASH_FUNC="SHA1"
case "${HASH_FUNC}" in
SHA1) SHA_SIZE=1
;;
SHA224) SHA_SIZE=224
;;
SHA256) SHA_SIZE=256
;;
SHA384) SHA_SIZE=384
;;
SHA512) SHA_SIZE=512
;;
esac
if [ "${HASH_FUNC}" = "SHA1" -a $PRELINKED -eq 1 ]; then
PRELINK_HASH="SHA1"
if [ $USE_RUNCON -eq 1 ]; then
HASH_FUNC="${RUNCON_CMD} -u root -- ${PRELINK_CMD} --verify --sha"
else
HASH_FUNC="${PRELINK_CMD} --verify --sha"
fi
elif [ $SHA_SIZE -gt 0 ]; then
HF=`find_cmd sha${SHA_SIZE}sum`
if [ -z "${HF}" ]; then
HF=`find_cmd sha${SHA_SIZE}`
if [ -z "${HF}" -a $MACOSX -eq 1 ]; then
HF=`find_cmd shasum`
test -n "${HF}" && HF="${HF} -a $SHA_SIZE"
fi
fi
if [ -z "${HF}" -a -n "${PERL_CMD}" ]; then
MOD_INSTALLED=""
if [ $SHA_SIZE -eq 1 ]; then
MOD_INSTALLED=`${PERL_CMD} "${SCRIPT_PATH}/check_modules.pl" Digest::SHA Digest::SHA1 Digest::SHA::PurePerl 2>/dev/null`
elif [ $SHA_SIZE -eq 224 ]; then
MOD_INSTALLED=`${PERL_CMD} "${SCRIPT_PATH}/check_modules.pl" Digest::SHA Digest::SHA::PurePerl 2>/dev/null`
else
MOD_INSTALLED=`${PERL_CMD} "${SCRIPT_PATH}/check_modules.pl" Digest::SHA Digest::SHA256 Digest::SHA::PurePerl 2>/dev/null`
fi
USE_MOD=`echo "${MOD_INSTALLED}" | grep -v 'NOT installed' | head ${HEAD_OPT}1 | cut -d' ' -f1`
if [ -n "${USE_MOD}" ]; then
HF="${PERL_CMD} "${SCRIPT_PATH}/filehashsha.pl" ${USE_MOD} $SHA_SIZE"
fi
fi
HASH_FUNC="${HF}"
elif [ "${HASH_FUNC}" = "RIPEMD160" ]; then
MOD_INSTALLED=`${PERL_CMD} "${SCRIPT_PATH}/check_modules.pl" Crypt::RIPEMD160 2>/dev/null`
if [ -n "`echo \"${MOD_INSTALLED}\" | grep 'Crypt::RIPEMD160 installed'`" ]; then
HASH_FUNC="${PERL_CMD} "${SCRIPT_PATH}/filehashsha.pl" Crypt::RIPEMD160 0"
fi
elif [ "${HASH_FUNC}" = "WHIRLPOOL" ]; then
MOD_INSTALLED=`${PERL_CMD} "${SCRIPT_PATH}/check_modules.pl" Digest::Whirlpool 2>/dev/null`
if [ -n "`echo \"${MOD_INSTALLED}\" | grep 'Digest::Whirlpool installed'`" ]; then
HASH_FUNC="${PERL_CMD} "${SCRIPT_PATH}/filehashsha.pl" Digest::Whirlpool 0"
fi
fi
#
# If we still have no hash function, then look for an MD5 command,
# but only if MD5 or SHA1 were specified.
#
if [ \( -z "${HASH_FUNC}" -a $SHA_SIZE -eq 1 \) -o "${HASH_FUNC}" = "MD5" ]; then
SHA_SIZE=0
HASH_FUNC=`get_md5_hash_function`
if [ $PRELINKED -eq 1 ]; then
PRELINK_HASH="MD5"
elif [ -z "`echo \"${HASH_FUNC}\" | grep '/filehashsha\.pl Digest::MD5'`" ]; then
MD5_CMD="${HASH_FUNC}"
fi
fi
#
# A final check that the command is actually executable.
# This will ensure that the SHA/MD5 perl scripts have been
# installed correctly, should they be needed.
#
if [ "${HASH_FUNC}" = "NONE" ]; then
:
elif [ "${HASH_FUNC}" = "RIPEMD160" -o "${HASH_FUNC}" = "WHIRLPOOL" ]; then
LEAVE=1
if [ $HASH_OPT -eq 1 ]; then
echo "Invalid '--hash' option: no perl module for ${HASH_FUNC} could be found."
else
echo "Invalid HASH_FUNC configuration option: no perl module for ${HASH_FUNC} could be found."
fi
elif [ -n "${HASH_FUNC}" ]; then
HASH_CMD=`echo "${HASH_FUNC}" | cut -d' ' -f1`
HF=`find_cmd ${HASH_CMD}`
if [ -n "${HF}" ]; then
#
# We rebuild the command to use the full pathname.
#
HASH_CMD=`echo "${HASH_FUNC}" | cut -d' ' -f2-`
if [ -z "${HASH_CMD}" -o "${HASH_CMD}" = "${HASH_FUNC}" ]; then
HASH_FUNC=$HF
else
HASH_FUNC="${HF} ${HASH_CMD}"
fi
elif [ $HASH_OPT -eq 1 ]; then
LEAVE=1
echo "Invalid '--hash' option: command is non-existent or not executable: ${HASH_CMD}"
else
LEAVE=1
echo "Invalid HASH_FUNC configuration option: command is non-existent or not executable: ${HASH_CMD}"
fi
elif [ $HASH_OPT -eq 1 ]; then
LEAVE=1
echo "Invalid '--hash' option: no usable hash command or perl modules could be found."
elif [ $SHA_SIZE -gt 1 ]; then
LEAVE=1
echo "Invalid HASH_FUNC configuration option: no usable hash command or perl module for SHA${SHA_SIZE} could be found."
else
LEAVE=1
echo "Invalid HASH_FUNC configuration option: no usable hash command or perl modules for SHA1 or MD5 could be found."
fi
#
# Now we get the hash field index. We will assume a field value
# of one, but this value must be configurable since we allow
# the user to specify the hash function to use.
#
RKHTMPVAR=`get_option single HASH_FLD_IDX` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${RKHTMPVAR}" ]; then
check_is_digit RKHTMPVAR HASH_FLD_IDX ANY1
if [ $ERRCODE -eq 0 ]; then
HASH_FLD_IDX=${RKHTMPVAR}
else
LEAVE=1
fi
fi
else
LEAVE=1
fi
#
# Next we get the package manager to use for the file
# properties hash check and update. If a file is not owned
# as part of a package, the hash function defined above
# will be used instead.
#
if [ -n "${PKGMGR}" ]; then
PKGMGR=`echo "${PKGMGR}" | tr -d '" ' | tr -d "'"`
if [ -z "${PKGMGR}" ]; then
LEAVE=1
echo "Invalid '--pkgmgr' option: no package manager given."
fi
else
PKGMGR=`get_option single PKGMGR` || exit 1
test $ERRCODE -eq 1 && LEAVE=1
fi
PKGMGR=`echo "${PKGMGR}" | tr '[:lower:]' '[:upper:]'`
test "${PKGMGR}" = "NONE" && PKGMGR=""
#
# Now check that the package manager we have been given is valid.
#
case "${PKGMGR}" in
"")
;;
RPM)
RPM_CMD=`find_cmd rpm`
if [ -z "${RPM_CMD}" ]; then
LEAVE=1
echo "Unable to find 'rpm' command for package manager 'RPM'."
fi
;;
DPKG)
DPKG_CMD=`find_cmd dpkg-query`
test -z "${DPKG_CMD}" && DPKG_CMD=`find_cmd dpkg`
if [ -z "${DPKG_CMD}" ]; then
LEAVE=1
echo "Unable to find 'dpkg-query' or 'dpkg' commands for package manager 'DPKG'."
elif [ ! -d "/var/lib/dpkg/info" ]; then
LEAVE=1
echo "Unable to find package database directory (/var/lib/dpkg/info) for package manager 'DPKG'."
fi
if [ $CHECK -eq 1 ]; then
PKGMGR_MD5_HASH=`get_md5_hash_function`
if [ -z "${PKGMGR_MD5_HASH}" ]; then
LEAVE=1
echo "Unable to find an MD5 hash function command to assist package manager 'DPKG'."
fi
fi
;;
BSD)
PKG_CMD=`find_cmd pkg_info`
if [ -z "${PKG_CMD}" ]; then
LEAVE=1
echo "Unable to find 'pkg_info' command for package manager 'BSD'."
elif [ ! -d "/var/db/pkg" ]; then
LEAVE=1
echo "Unable to find package database directory (/var/db/pkg) for package manager 'BSD'."
fi
if [ $CHECK -eq 1 ]; then
PKGMGR_MD5_HASH=`get_md5_hash_function`
if [ -z "${PKGMGR_MD5_HASH}" ]; then
LEAVE=1
echo "Unable to find an MD5 hash function command to assist package manager 'BSD'."
fi
fi
;;
SOLARIS)
#
# For the Solaris package manager, see if we want
# to use the stored 16-bit checksum or not.
#
USE_SUNSUM=`get_option single USE_SUNSUM` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${USE_SUNSUM}" ]; then
check_is_digit USE_SUNSUM
if [ $ERRCODE -eq 0 ]; then
SUM_CMD=`find_cmd sum`
if [ -z "${SUM_CMD}" ]; then
LEAVE=1
echo "Unable to find 'sum' command for package manager 'SOLARIS'."
fi
else
LEAVE=1
fi
else
USE_SUNSUM=0
fi
if [ ! -f "/var/sadm/install/contents" ]; then
LEAVE=1
echo "Unable to find package database file (/var/sadm/install/contents) for package manager 'SOLARIS'."
fi
else
LEAVE=1
fi
;;
*)
LEAVE=1
echo "Invalid package manager given: ${PKGMGR}"
;;
esac
#
# Finally we see if any files are to be exempt from the
# package manager verification. These will go through the
# usual commands to get the file info, so they will still
# be tested.
#
PKGMGRNOVRFY=`get_option newline-list PKGMGR_NO_VRFY` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${PKGMGRNOVRFY}" ]; then
check_paths PKGMGRNOVRFY PKGMGR_NO_VRFY "EXIST NOWILD NOBROKENLINK"
test $ERRCODE -eq 1 && LEAVE=1
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_scan_mode_dev_option() {
#
# SCAN_MODE_DEV governs how we scan '/dev' for suspicious files.
# The two allowed values are "THOROUGH" or "LAZY". If the option
# is commented out, the default, then we do a THOROUGH scan, which
# will increase the runtime of rkhunter.
#
#
# See if the option is specified in the configuration file.
#
LEAVE=0
SCAN_MODE_DEV=`get_option single SCAN_MODE_DEV` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${SCAN_MODE_DEV}" ]; then
SCAN_MODE_DEV=`echo "${SCAN_MODE_DEV}" | tr '[:lower:]' '[:upper:]'`
case "${SCAN_MODE_DEV}" in
THOROUGH|LAZY)
;;
*) # Don't make this fatal.
echo "Invalid SCAN_MODE_DEV configuration option: ${SCAN_MODE_DEV}"
echo "Defaulting to THOROUGH mode."
SCAN_MODE_DEV="THOROUGH"
;;
esac
else
SCAN_MODE_DEV="THOROUGH"
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_startup_paths_option() {
#
# This function gets the system startup files and directories
# from the configuration file. There are no defaults.
#
LEAVE=0
STARTUP_PATHS=`get_option space-list STARTUP_PATHS` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${STARTUP_PATHS}" ]; then
#
# First see if we have any startup files or not.
#
if [ -n "`echo \"${STARTUP_PATHS}\" | grep -i '^none$'`" ]; then
STARTUP_PATHS="NONE"
else
#
# Check that the given files and directories are usable.
#
check_paths STARTUP_PATHS STARTUP_PATHS "EXIST"
if [ $ERRCODE -eq 0 ]; then
for FNAME in ${STARTUP_PATHS}; do
test -f "${FNAME}" && RKHTMPVAR="file" || RKHTMPVAR="directory"
if [ -h "${FNAME}" ]; then
LEAVE=1
echo "Invalid STARTUP_PATHS configuration option: the ${RKHTMPVAR} is a link: ${FNAME}"
elif [ ! -r "${FNAME}" ]; then
LEAVE=1
echo "Invalid STARTUP_PATHS configuration option: the ${RKHTMPVAR} is not readable: ${FNAME}"
elif [ ! -s "${FNAME}" ]; then
LEAVE=1
echo "Invalid STARTUP_PATHS configuration option: the ${RKHTMPVAR} is empty: ${FNAME}"
fi
done
else
LEAVE=1
fi
fi
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_rtkt_whitelist_options() {
#
# This function gets any whitelisted rootkit files
# and directories from the configuration file.
# There are no defaults.
#
LEAVE=0
RTKT_FILE_WHITELIST=`get_option newline-list RTKT_FILE_WHITELIST` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${RTKT_FILE_WHITELIST}" ]; then
#
# Check that the given files are usable. But we must
# first strip off any trailing text from the end if
# it is present.
#
IFS=$IFSNL
RKHTMPVAR=""
for RKHTMPVAR2 in ${RTKT_FILE_WHITELIST}; do
FNAME=`echo "${RKHTMPVAR2}" | sed -e 's/^\(.*\):[^:]*$/\1/'`
RKHTMPVAR="${RKHTMPVAR}
${FNAME}"
done
IFS=$RKHIFS
RKHTMPVAR=`echo "${RKHTMPVAR}" | sed -e '/^$/d'`
check_paths RKHTMPVAR RTKT_FILE_WHITELIST "EXIST NOWILD NOBROKENLINK"
test $ERRCODE -eq 1 && LEAVE=1
fi
else
LEAVE=1
fi
RTKT_DIR_WHITELIST=`get_option newline-list RTKT_DIR_WHITELIST` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${RTKT_DIR_WHITELIST}" ]; then
#
# Check that the given directories are usable.
#
check_paths RTKT_DIR_WHITELIST RTKT_DIR_WHITELIST "EXIST NOWILD NOBROKENLINK"
test $ERRCODE -eq 1 && LEAVE=1
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_shared_lib_whitelist_option() {
#
# This function gets any whitelisted shared library files
# from the configuration file. There are no defaults.
#
LEAVE=0
SHARED_LIB_WHITELIST=`get_option space-list SHARED_LIB_WHITELIST` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${SHARED_LIB_WHITELIST}" ]; then
check_paths SHARED_LIB_WHITELIST SHARED_LIB_WHITELIST "EXIST NOWILD NOBROKENLINK"
if [ $ERRCODE -eq 0 ]; then
SHARED_LIB_WHITELIST=" ${SHARED_LIB_WHITELIST} "
else
LEAVE=1
fi
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_mirror_options() {
#
# This function gets the mirrors file options.
#
#
# First we see if the mirrors.dat file
# should be rotated when it is used.
#
LEAVE=0
ROTATE_MIRRORS=`get_option single ROTATE_MIRRORS` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${ROTATE_MIRRORS}" ]; then
check_is_digit ROTATE_MIRRORS
test $ERRCODE -eq 1 && LEAVE=1
else
ROTATE_MIRRORS=1
fi
#
# Now check that the mirrors file is usable.
#
if [ -e "${DB_PATH}/mirrors.dat" -a \( ! -f "${DB_PATH}/mirrors.dat" -o -h "${DB_PATH}/mirrors.dat" \) ]; then
LEAVE=1
echo "The mirrors file is not a file: ${DB_PATH}/mirrors.dat"
fi
if [ $LEAVE -eq 0 -a $VERSIONCHECK -eq 1 ]; then
if [ $ROTATE_MIRRORS -eq 0 ]; then
# The mirrors file only needs to be readable.
if [ ! -e "${DB_PATH}/mirrors.dat" -o ! -s "${DB_PATH}/mirrors.dat" ]; then
LEAVE=1
echo "The mirrors file does not exist or is empty: ${DB_PATH}/mirrors.dat"
echo "Run 'rkhunter --update'" to restore the default mirrors file.
echo "The default mirror will be used."
fi
else
# The mirrors file needs to be writable.
if [ ! -e "${DB_PATH}/mirrors.dat" -o ! -s "${DB_PATH}/mirrors.dat" ]; then
LEAVE=1
echo "The mirrors file does not exist or is empty: ${DB_PATH}/mirrors.dat"
echo "Run 'rkhunter --update'" to restore the default mirrors file.
elif [ ! -w "${DB_PATH}/mirrors.dat" ]; then
LEAVE=1
echo "The mirrors file is not writable: ${DB_PATH}/mirrors.dat"
fi
fi
fi
else
LEAVE=1
fi
#
# Next we see if the mirrors file is to be updated when
# we use the '--update' option.
#
if [ $UPDATE -eq 1 ]; then
UPDATE_MIRRORS=`get_option single UPDATE_MIRRORS` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${UPDATE_MIRRORS}" ]; then
check_is_digit UPDATE_MIRRORS
test $ERRCODE -eq 1 && LEAVE=1
else
UPDATE_MIRRORS=1
fi
else
LEAVE=1
fi
fi
#
# Finally, we see which mirrors are to be used.
#
MIRRORS_MODE=`get_option single MIRRORS_MODE` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${MIRRORS_MODE}" ]; then
check_is_digit MIRRORS_MODE MIRRORS_MODE 2
test $ERRCODE -eq 1 && LEAVE=1
else
MIRRORS_MODE=0
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_os_info_options() {
#
# This function gets configuration options relating
# to obtaining information about the O/S.
#
# The first part gets the 'release' file pathname
# from the configuration file. There is no default.
#
LEAVE=0
OS_VERSION_FILE=`get_option single OS_VERSION_FILE` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${OS_VERSION_FILE}" ]; then
#
# Check that the given file is usable.
#
check_paths OS_VERSION_FILE OS_VERSION_FILE "EXIST NOWILD NOBROKENLINK"
if [ $ERRCODE -eq 0 ]; then
if [ ! -r "${OS_VERSION_FILE}" ]; then
LEAVE=1
echo "Invalid OS_VERSION_FILE configuration option: File is not readable: ${OS_VERSION_FILE}"
elif [ ! -s "${OS_VERSION_FILE}" ]; then
LEAVE=1
echo "Invalid OS_VERSION_FILE configuration option: File is empty: ${OS_VERSION_FILE}"
fi
else
LEAVE=1
fi
fi
else
LEAVE=1
fi
#
# Next we get the option as to whether we should
# issue a warning when the O/S info changes or not.
#
WARN_ON_OS_CHANGE=`get_option single WARN_ON_OS_CHANGE` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${WARN_ON_OS_CHANGE}" ]; then
check_is_digit WARN_ON_OS_CHANGE
test $ERRCODE -eq 1 && LEAVE=1
else
WARN_ON_OS_CHANGE=1
fi
else
LEAVE=1
fi
#
# Now get the option as to whether we should automatically run
# a properties update ('--propupd') if the O/S has changed.
#
UPDT_ON_OS_CHANGE=`get_option single UPDT_ON_OS_CHANGE` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${UPDT_ON_OS_CHANGE}" ]; then
check_is_digit UPDT_ON_OS_CHANGE
test $ERRCODE -eq 1 && LEAVE=1
else
UPDT_ON_OS_CHANGE=0
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_user_fileprop_list() {
#
# This function gets any user supplied files and directories
# for the file properties check and the properties file update.
# It stores the different types of files and directories
# found in different variables. Only basic syntax checking is
# done here, further checking will be done later on.
#
# The configuration options can have three basic values:
#
# 1) A simple file (command) name - for example, 'top'
# 2) A directory - for example, '/usr/local/sbin'
# 3) A full file pathname - for example, '/usr/local/sbin/backup'
#
# The first two are simply added to the internal lists of files
# and directories. These are then used to build the file properties
# file list. The third type is added directly to the end of the file.
#
# The second and third types may be wildcarded. They may also be
# excluded from the checks by including them in the
# EXCLUDE_USER_FILEPROP_FILES_DIRS option. Only files and directories
# matching user added ones can be excluded. This prevents users from
# excluding anything in the internal list.
# For example: USER_FILEPROP_FILES_DIRS=/opt/b*
# EXCLUDE_USER_FILEPROP_FILES_DIRS=/opt/backup
#
LEAVE=0
for WHICH_OPT in USER_FILEPROP_FILES_DIRS EXCLUDE_USER_FILEPROP_FILES_DIRS; do
FILENAMES=`get_option newline-list ${WHICH_OPT}` || exit 1
if [ $ERRCODE -eq 1 ]; then
LEAVE=1
continue
fi
test -z "${FILENAMES}" && continue
#
# We must first check to see if any of the names are
# simple names but with wildcard characters included.
#
RKHTMPVAR=`echo "${FILENAMES}" | grep '^[^/]*[][?*{}]'`
if [ -n "${RKHTMPVAR}" ]; then
LEAVE=1
# Make a space-separated list but without expanding the wildcards.
RKHTMPVAR=`make_space_list "${RKHTMPVAR}"`
echo "Invalid ${WHICH_OPT} configuration option: Invalid pathname(s): ${RKHTMPVAR}"
fi
#
# Next check the pathnames to ensure they are basically valid.
#
check_paths FILENAMES ${WHICH_OPT} "EXIST"
if [ $ERRCODE -eq 1 ]; then
LEAVE=1
continue
fi
#
# Now expand any wildcards.
#
FNAMES=`expand_paths FILENAMES`
#
# Now we loop through the entries and check them again. They
# are then added to the relevant variable used to build the
# file properties file list.
#
IFS=$IFSNL
for FNAME in ${FNAMES}; do
#
# First check for any files or directories to be excluded.
# We ignore any real checks on the pathnames since it is
# safer if they fail (the relevant files/directories will
# then be included in the file properties checks).
#
if [ "${WHICH_OPT}" = "EXCLUDE_USER_FILEPROP_FILES_DIRS" ]; then
test -z "${USER_EXCLUDE_PROP}" && USER_EXCLUDE_PROP="${FNAME}" || USER_EXCLUDE_PROP="${USER_EXCLUDE_PROP}
${FNAME}"
continue
fi
#
# Now check to see if it is a simple file name.
#
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -z "`echo \"${FNAME}\" | grep '^/'`" ]; then
# Check that the file name hasn't already been set. If it has, then we just ignore it.
if [ -z "`echo \"${USER_SIMPLE_FILE_LIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
test -z "${USER_SIMPLE_FILE_LIST}" && USER_SIMPLE_FILE_LIST="${FNAME}" || USER_SIMPLE_FILE_LIST="${USER_SIMPLE_FILE_LIST}
${FNAME}"
fi
else
# It's an absolute pathname. This could be a file or a directory.
if [ -f "${FNAME}" -o -h "${FNAME}" ]; then
# Check that it hasn't already been set. If it has, then we just ignore it.
test -n "`echo \"${USER_FILE_LIST}\" | grep \"^${FNAMEGREP}$\"`" && continue
if [ -h "${FNAME}" -a $HAVE_READLINK -eq 1 ]; then
RKHTMPVAR=`${READLINK_CMD} -f "${FNAME}"`
if [ -n "${RKHTMPVAR}" ]; then
FNAMEGREP=`echo "${RKHTMPVAR}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -z "`echo \"${USER_FILE_LIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
FNAME="${FNAME}
${RKHTMPVAR}"
fi
elif [ -z "`echo \"${EXISTWHITELIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
LEAVE=1
echo "Invalid ${WHICH_OPT} configuration option: Broken link found: ${FNAME}"
continue
fi
fi
#
# Now add the file name.
#
test -z "${USER_FILE_LIST}" && USER_FILE_LIST="${FNAME}" || USER_FILE_LIST="${USER_FILE_LIST}
${FNAME}"
elif [ -d "${FNAME}" ]; then
if [ -h "${FNAME}" -a $HAVE_READLINK -eq 1 ]; then
RKHTMPVAR=`${READLINK_CMD} -f "${FNAME}"`
if [ -z "${RKHTMPVAR}" ]; then
if [ -z "`echo \"${EXISTWHITELIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
LEAVE=1
echo "Invalid ${WHICH_OPT} configuration option: Broken link found: `name2text \"${FNAME}\"`"
continue
fi
elif [ "${RKHTMPVAR}" = "/" ]; then
LEAVE=1
echo "Invalid ${WHICH_OPT} configuration option: Invalid pathname: `name2text \"${FNAME}\"` -> /"
continue
fi
FNAME="${RKHTMPVAR}"
fi
#
# Check that the name hasn't already been set. If it has, then we just ignore it.
#
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -z "`echo \"${USER_DIR_LIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
test -z "${USER_DIR_LIST}" && USER_DIR_LIST="${FNAME}" || USER_DIR_LIST="${USER_DIR_LIST}
${FNAME}"
fi
fi
fi
done
IFS=$RKHIFS
done
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_properties_options() {
#
# This function gets any configuration options required for
# the file properties check and the properties file update.
#
# For options where filenames are specified, the existence
# of the filename is checked.
#
check_test hashes && HASH_CHECK_ENABLED=1
check_test attributes && HASH_CHECK_ENABLED=1
LEAVE=0
ATTRWHITELIST=""
ATTRWL_OPT=`get_option newline-list ATTRWHITELIST` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${ATTRWL_OPT}" ]; then
ATTRWHITELIST=`expand_paths ATTRWL_OPT`
check_paths ATTRWHITELIST ATTRWHITELIST "EXIST"
test $ERRCODE -eq 1 && LEAVE=1
fi
else
LEAVE=1
fi
WRITEWHITELIST=""
WRITEWL_OPT=`get_option newline-list WRITEWHITELIST` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${WRITEWL_OPT}" ]; then
WRITEWHITELIST=`expand_paths WRITEWL_OPT`
check_paths WRITEWHITELIST WRITEWHITELIST "EXIST"
test $ERRCODE -eq 1 && LEAVE=1
fi
else
LEAVE=1
fi
IMMUTWHITELIST=""
IMMUTWL_OPT=`get_option newline-list IMMUTWHITELIST` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${IMMUTWL_OPT}" ]; then
IMMUTWHITELIST=`expand_paths IMMUTWL_OPT`
check_paths IMMUTWHITELIST IMMUTWHITELIST "EXIST"
test $ERRCODE -eq 1 && LEAVE=1
fi
else
LEAVE=1
fi
IMMUTABLE_SET=`get_option single IMMUTABLE_SET` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${IMMUTABLE_SET}" ]; then
check_is_digit IMMUTABLE_SET
test $ERRCODE -eq 1 && LEAVE=1
else
IMMUTABLE_SET=0
fi
else
LEAVE=1
fi
SCRIPTWHITELIST=""
SCRIPTWL_OPT=`get_option newline-list SCRIPTWHITELIST` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${SCRIPTWL_OPT}" ]; then
SCRIPTWHITELIST=`expand_paths SCRIPTWL_OPT`
check_paths SCRIPTWHITELIST SCRIPTWHITELIST "EXIST"
test $ERRCODE -eq 1 && LEAVE=1
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_prelink_dep_option() {
#
# This function gets the prelink dependency error option.
# This option is a workaround for any files which persistently
# give a prelinking dependency error.
#
LEAVE=0
RKHTMPVAR=`get_option space-list IGNORE_PRELINK_DEP_ERR` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${RKHTMPVAR}" ]; then
check_paths RKHTMPVAR IGNORE_PRELINK_DEP_ERR "EXIST NOWILD NOBROKENLINK"
if [ $ERRCODE -eq 0 ]; then
PRELINK_DEP_ERR_CMDS=" ${RKHTMPVAR} "
else
LEAVE=1
fi
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_summary_options() {
#
# Get the configuration options for the summary.
#
#
# Get the option to see if we are to show the
# actual number of warnings in the summary.
#
LEAVE=0
SHOW_SUMMARY_WARNINGS_NUMBER=`get_option single SHOW_SUMMARY_WARNINGS_NUMBER` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${SHOW_SUMMARY_WARNINGS_NUMBER}" ]; then
check_is_digit SHOW_SUMMARY_WARNINGS_NUMBER
test $ERRCODE -eq 1 && LEAVE=1
else
SHOW_SUMMARY_WARNINGS_NUMBER=0
fi
else
LEAVE=1
fi
#
# Get the option to see where, if at all,
# we are to show the summary scan time.
#
SHOW_SUMMARY_TIME=`get_option single SHOW_SUMMARY_TIME` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${SHOW_SUMMARY_TIME}" ]; then
check_is_digit SHOW_SUMMARY_TIME SHOW_SUMMARY_TIME ANY
if [ $ERRCODE -eq 0 ]; then
if [ $SHOW_SUMMARY_TIME -gt 3 ]; then
LEAVE=1
echo "Invalid SHOW_SUMMARY_TIME configuration option: not a valid number: ${SHOW_SUMMARY_TIME}"
fi
else
LEAVE=1
fi
else
SHOW_SUMMARY_TIME=3
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_network_options() {
#
# Get any options used for network tests.
#
LEAVE=0
IFWLIST=`get_option space-list ALLOWPROMISCIF` || exit 1
test $ERRCODE -eq 1 && LEAVE=1
ALLOWPROCLIST_OPT=`get_option newline-list ALLOWPROCLISTEN` || exit 1
test $ERRCODE -eq 1 && LEAVE=1
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_os_specific_options() {
#
# Get any O/S specific options.
#
LEAVE=0
if [ $LINUXOS -eq 1 ]; then
LKM_PATH=`get_option single MODULES_DIR` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -z "${LKM_PATH}" ]; then
LKM_PATH="/lib/modules/`uname -r 2>/dev/null`"
test ! -d "${LKM_PATH}" && LKM_PATH="/lib/modules"
fi
check_paths LKM_PATH MODULES_DIR "NOBROKENLINK NOWILD"
test $ERRCODE -eq 1 && LEAVE=1
else
LEAVE=1
fi
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_app_options() {
#
# Get any options used for the application check.
#
LEAVE=0
APP_WHITELIST=""
RKHTMPVAR=`get_option space-list APP_WHITELIST` || exit 1
if [ $ERRCODE -eq 0 ]; then
if [ -n "${RKHTMPVAR}" ]; then
APP_WHITELIST=`echo " ${RKHTMPVAR} " | tr '[:upper:]' '[:lower:]'`
fi
else
LEAVE=1
fi
if [ $LEAVE -eq 1 ]; then
if [ $CONFIG_CHECK -eq 0 ]; then
exit 1
else
RET_CODE=1
fi
fi
return
}
get_configfile_options() {
#
# We call separate functions to process each option. The option
# is checked first to see if it has been given on the command-line,
# and, if not, then if it is specified in the configuration file.
# Note that some of these functions are in a specific order. If you
# change them around, then make sure the functions still work
# correctly.
#
get_bindir_option
get_scriptdir_option
#
# Now that we have processed BINDIR, we will recheck the required
# commands.
#
# Before proceeding too far we also check that we have certain
# commands available. Typically these are commands which might
# not have been installed as part of the core system, but are
# used by RKH. These commands are not 'required' though.
#
check_required_commands 2
check_commands
get_installdir_option
get_rootdir_option
get_logfile_option
get_tmpdir_option
get_dbdir_option
get_language_option
get_auto_x_option
get_locking_options
#
# Some options are only required when checking the system.
#
if [ $CHECK -eq 1 -o $PROP_UPDATE -eq 1 -o $CONFIG_CHECK -eq 1 ]; then
#
# See if we are only to perform specific tests.
#
get_enable_option
get_disable_option
check_test_options
get_existwl_option
fi
if [ $CHECK -eq 1 -o $CONFIG_CHECK -eq 1 ]; then
get_syslog_option
get_startup_paths_option
get_rtkt_whitelist_options
get_epoch_date_cmd_option
get_phalanx2_option
get_summary_options
test $NOMOW -eq 0 && get_mailonwarn_option
if `check_test system_configs`; then
get_ssh_options
get_syslog_config_options
fi
if `check_test filesystem`; then
get_scan_mode_dev_option
get_missing_file_options
get_hidden_options
get_dev_options
fi
check_test trojans && get_xinetd_option
check_test ports || check_test hidden_ports && get_port_options
check_test group_accounts && get_groups_accounts_options
check_test shared_libs && get_shared_lib_whitelist_option
check_test hidden_procs || check_test hidden_ports && get_unhide_options
check_test deleted_files && get_process_options
check_test suspscan && get_suspscan_options
check_test network && get_network_options
check_test os_specific && get_os_specific_options
check_test apps && get_app_options
fi
#
# We only need the hash function option if we are going
# to be checking the system or updating the file
# properties database.
#
if `check_test properties` || test $PROP_UPDATE -eq 1 || test $CONFIG_CHECK -eq 1; then
#
# For the file properties check we need to find out if
# we are a prelinked system, and if so, then find out
# which hash function to use. Secondly, we need to find
# the 'stat' command. Finally, we need to see if the
# user has specified any files or directories for the
# file properties check.
#
get_if_prelinked
get_hash_function
get_os_info_options
get_user_fileprop_list
get_properties_options
fi
#
# If we are doing a file properties update, then we need to
# see if we should be ignoring prelink errors for any files.
#
if [ $PROP_UPDATE -eq 1 -o $CONFIG_CHECK -eq 1 ]; then
get_prelink_dep_option
fi
#
# Get any set options when doing an update or version check.
#
if [ $UPDATE -eq 1 -o $VERSIONCHECK -eq 1 -o $CONFIG_CHECK -eq 1 ]; then
get_mirror_options
get_webcmd_option
fi
return
}
get_readable_date() {
#
# This function returns a given epoch second time as a
# human-readable date and time. It sets the READABLE_DATE
# variable.
#
EPOCH_SECS=$1
READABLE_DATE=""
if [ "${EPOCH_DATE_CMD}" = "NONE" ]; then
:
elif [ -n "${EPOCH_DATE_CMD}" ]; then
EPOCH_NOW=`${EPOCH_DATE_CMD} '+%s'`
EPOCH_SECS=`expr $EPOCH_NOW - $EPOCH_SECS`
READABLE_DATE=`${EPOCH_DATE_CMD} --date "$EPOCH_SECS seconds ago" '+%d-%b-%Y %H:%M:%S' 2>/dev/null`
elif [ -n "${PERL_CMD}" ]; then
READABLE_DATE=`${PERL_CMD} -e "@a=split(' ',scalar(localtime($EPOCH_SECS))); printf \"%d-%s-%d %s\",\\$a[2],\\$a[1],\\$a[4],\\$a[3];" 2>/dev/null`
fi
return
}
rkh_dat_set_version() {
#
# This function calculates and writes out the 'Version:' value
# for the rkhunter.dat file. It looks for an old value, and adds
# one to it. If there is no value then simply start at zero.
#
# Note that the new temporary rkhunter.dat file is used.
#
TODAY=`date +%Y%m%d 2>/dev/null`
OLDVER=`grep '^[Vv]ersion:' "${RKHDAT_FILE}" 2>/dev/null | tail ${TAIL_OPT}1 | cut -d: -f2`
if [ -n "${OLDVER}" ]; then
OLDDATE=`echo "${OLDVER}" | cut -c1-8`
OLDVER=`echo "${OLDVER}" | cut -c9-10`
if [ "${OLDVER}" = "99" -o "${OLDDATE}" != "${TODAY}" -o -z "${OLDVER}" -o -n "`echo \"${OLDVER}\" | grep '[^0-9]'`" ]; then
NEWVER="00"
else
NEWVER=`expr ${OLDVER} + 1`
test $NEWVER -lt 10 && NEWVER="0${NEWVER}"
fi
else
NEWVER="00"
fi
echo "Version:${TODAY}${NEWVER}" >>"${RKHDAT_TMPFILE}"
return
}
rkh_dat_get_os_info() {
#
# This function obtains information about the local computer
# system. This is then written into the rkhunter.dat file
# using a simple 'keyword:<value>' format. The OSNAME and
# ARCH values are not important, but are simply used to check
# whether they have changed since RKH was last run.
#
# Obtaining the OSNAME is somewhat tricky. There is no sure
# way of finding the information, so we have to use some tricks
# to locate the correct file. First we look for certain specific
# O/S release files, and then at the /etc/release file, but not
# if it is a link. Next we look for a generic /etc/*-release
# file, again not as a link. This should find most O/S versions.
# Overall this should also save users having to ask us to support
# their O/S. In other cases, we will have to ask what file does
# contain their O/S release information.
#
ARCH=""
OSNAME=""
RELEASE=""
if [ -n "${OS_VERSION_FILE}" ]; then
REL_FILES="${OS_VERSION_FILE}"
else
REL_FILES="/etc/system-release /etc/os-release /etc/lsb-release /etc/debian_version /etc/slackware-version /var/ipcop/general-functions.pl /etc/lunar.release /etc/ROCK-VERSION /etc/GoboLinuxVersion /etc/kanotix-version /etc/sidux-version /etc/knoppix-version /etc/zenwalk-version /etc/release /etc/*-release"
fi
RKH_LSB_SEEN=0
for FNAME in ${REL_FILES}; do
test ! -f "${FNAME}" && continue
if [ "${FNAME}" = "/etc/system-release" ]; then
RKH_IN_LSB=0
RELEASE=$FNAME
OSNAME=`cat "${FNAME}"`
break
elif [ ! -h "${FNAME}" ]; then
RELEASE=$FNAME
RKH_IN_LSB=0
case "${RELEASE}" in
/etc/os-release)
OSNAME=`grep '^PRETTY_NAME=' "${RELEASE}" | sed -e 's/PRETTY_NAME=//' | tr -d '"'`
if [ -z "${OSNAME}" ]; then
RKHTMPVAR=`grep '^NAME=' "${RELEASE}" | sed -e 's/NAME=//'`;
RKHTMPVAR2=`grep '^VERSION=' "${RELEASE}" | sed -e 's/VERSION=//' | tr -d '"'`;
OSNAME="${RKHTMPVAR} ${RKHTMPVAR2}"
fi
;;
/etc/lsb-release)
RKH_IN_LSB=1
RKH_LSB_SEEN=1
OSNAME=`grep '^DISTRIB_DESCRIPTION=' "${RELEASE}" | sed -e 's/DISTRIB_DESCRIPTION=//' | tr -d '"'`
;;
/etc/gentoo-release)
if [ -h "/etc/make.profile" ]; then
OSNAME="Gentoo `ls -l /etc/make.profile 2>/dev/null | sed -e 's;^.*/\([^/]*/[^/]*\)$;\1;' | tr '/' ' '`"
else
OSNAME="Gentoo"
fi
;;
/var/ipcop/general-functions.pl)
OSNAME=`grep 'version *=' "${RELEASE}" | head ${HEAD_OPT}1`
;;
/etc/debian_version)
OSNAME="Debian `cat \"${RELEASE}\"`"
;;
/etc/GoboLinuxVersion)
OSNAME="GoboLinux `cat \"${RELEASE}\"`"
;;
/etc/knoppix-version)
OSNAME="Knoppix `cat \"${RELEASE}\"`"
;;
/etc/zenwalk-version)
OSNAME="Zenwalk `cat \"${RELEASE}\"`"
;;
*)
OSNAME=`awk '/^[ ]*[^ ]/ { print $0 }' "${RELEASE}" | head ${HEAD_OPT}1`
;;
esac
#
# Strip out any leading blanks and tabs from the O/S version.
#
test -n "${OSNAME}" && OSNAME=`echo ${OSNAME}`
#
# If we have a release file but it seems to be blank,
# and we are not looking at the LSB release file, then
# we take a look for the first non-blank line. We
# then, again, strip out any leading blanks and tabs.
#
if [ $RKH_IN_LSB -eq 0 -a -z "${OSNAME}" ]; then
OSNAME=`awk '/^[ ]*[^ ]/ { print $0 }' "${RELEASE}" | head ${HEAD_OPT}1`
OSNAME=`echo ${OSNAME}`
fi
test -n "${OSNAME}" && break
fi
done
if [ -z "${OSNAME}" ]; then
RELEASE=""
if [ -d "/var/smoothwall" ]; then
OSNAME="Smoothwall Linux"
RELEASE="/var/smoothwall"
elif [ -n "`which sorcery 2>/dev/null | grep -v ' '`" -a -n "`which gaze 2>/dev/null | grep -v ' '`" ]; then
OSNAME="Source Mage Linux"
fi
fi
case "${OPERATING_SYSTEM}" in
SunOS)
ARCH=`uname -p 2>/dev/null`
;;
FreeBSD|DragonFly)
ARCH=`sysctl -n hw.machine_arch 2>/dev/null`
OSNAME=`uname -v 2>/dev/null | cut -d' ' -f1,2`
;;
OpenBSD)
OSNAME="OpenBSD `uname -r 2>/dev/null`"
;;
Darwin)
OSNAME=`sw_vers 2>/dev/null | grep '^ProductName:' | sed -e 's/ProductName:[ ]*//'`
OSNAME="${OSNAME} `sw_vers 2>/dev/null | grep '^ProductVersion:' | sed -e 's/ProductVersion:[ ]*//'`"
# OSNAME="${OSNAME} `sysctl kern.version 2>/dev/null | sed -e 's/^kern.version = //' | cut -d: -f1`"
if [ -n "`sysctl -a 2>/dev/null | egrep '^(hw\.optional\.x86_64|hw\.optional\.64bitops|hw\.cpu64bit_capable).*1$'`" ]; then
OSNAME="${OSNAME} (64-bit capable)"
fi
;;
AIX)
ARCH=`uname -p 2>/dev/null`
OSNAME="IBM AIX `oslevel 2>/dev/null`"
;;
IRIX*)
OSNAME="${OPERATING_SYSTEM} `uname -r 2>/dev/null`"
;;
esac
#
# If we still have no O/S version information, then as a last
# resort we will look to see if an 'issue' file exists or use
# whatever is in the LSB release file. We test these last because
# they are not necessarily reliable in providing the O/S version.
#
# However, if an O/S has been found, but it seems to be just a
# version number, then we look for the first word in the 'issue'
# file and prepend that. Hopefully, it will make sense!
#
if [ -z "${OSNAME}" ]; then
if [ -f "/etc/issue" ]; then
OSNAME=`awk '/^[ ]*[^ ]/ { print $0 }' /etc/issue | head ${HEAD_OPT}1`
OSNAME=`echo ${OSNAME}`
test -n "${OSNAME}" && RELEASE="/etc/issue"
fi
if [ $RKH_LSB_SEEN -eq 1 -a -z "${OSNAME}" ]; then
OSNAME=`awk '/^[ ]*[^ ]/ { print $0 }' /etc/lsb-release | head ${HEAD_OPT}1`
OSNAME=`echo ${OSNAME}`
test -n "${OSNAME}" && RELEASE="/etc/lsb-release"
fi
elif [ -n "`echo \"${OSNAME}\" | grep '^[0-9.][0-9.]*$'`" ]; then
if [ -f "/etc/issue" ]; then
RKHTMPVAR=`awk '/^[ ]*[^ ]/ { print $1 }' /etc/issue | head ${HEAD_OPT}1`
test -n "${RKHTMPVAR}" && OSNAME="${RKHTMPVAR} ${OSNAME}"
fi
fi
#
# If some things have still not been set, then set them now.
#
test -z "${ARCH}" && ARCH=`uname -m 2>/dev/null`
test -z "${OSNAME}" && OSNAME="`uname` `uname -r 2>/dev/null`"
return
}
rkh_dat_set_file_properties() {
#
# This function obtains various bits of information about the files to
# be checked. The current format in the rkhunter.dat file is:
#
# File:<colon count>:<pathname>:<hash value>:<inode>:<permissions>:
# <uid>:<gid>:<file size>:<date/time modified>:<package name>:
# <symbolic link colon count>:<symbolic link target>
#
# The format is actually governed by the stat.pl file, and the output
# it produces. Changing the order of options does not change the order
# of the output.
#
# To save time in the loops below, we determine the exact commands
# required before using them.
#
NODATFILE=0
NOHASH_COUNT=0
BROKEN_LINK_COUNT=0
PROP_FILE_LIST_COUNT=0
PROP_FILE_PROPOPT_COUNT=0
DIR_FILE_COUNT=""
display --to LOG --type PLAIN SET_FILE_PROP_START
if ! `check_test attributes` && test $ENDIS_OPT -eq 0; then
SCMD=""
INODECMD=""
elif [ -z "${STAT_CMD}" ]; then
SCMD=""
INODECMD=""
else
if [ -n "`echo \"${STAT_CMD}\" | grep '\.pl$'`" ]; then
if [ "${PKGMGR}" = "SOLARIS" ]; then
SCMD="${STAT_CMD} --modeoct --raw --ino --mode --uid --gid --size --mtime"
else
SCMD="${STAT_CMD} --modeoct --raw --ino --mode --uid --gid --size --Mtime"
fi
INODECMD="${STAT_CMD} --modeoct --raw --ino"
elif [ $BSDOS -eq 1 -o $MACOSX -eq 1 ]; then
SCMD="${STAT_CMD} -f '%i %Mp%Lp %u %g %z %m:'"
INODECMD="${STAT_CMD} -f '%i'"
else
SCMD="${STAT_CMD} -c '%i 0%a %u %g %s %Y:'"
INODECMD="${STAT_CMD} -c '%i'"
fi
fi
if ! `check_test hashes` && test $ENDIS_OPT -eq 0; then
HASH_CMD=""
elif [ -z "${PKGMGR}" -a "${HASH_FUNC}" = "NONE" ]; then
HASH_CMD=""
else
HASH_CMD="${HASH_FUNC}"
fi
#
# Next dig out the old file format version. We may need this if
# we are only updating one file and the format has changed.
#
if [ -s "${RKHDAT_FILE}" ]; then
OLD_FMTVERSION=`grep '^FormatVersion:' "${RKHDAT_FILE}" 2>/dev/null | cut -d: -f2`
test -z "${OLD_FMTVERSION}" && OLD_FMTVERSION=0
else
NODATFILE=1
fi
#
# Now loop through the pathnames looking for the files.
#
# We must set IFS around this loop, otherwise any names in the file
# properties list containing whitespace will be separated out.
# However, because IFS interacts with some commands, executed via
# backticks, we must then reset IFS for the duration of the loop
# and set it again at the end of the loop. It's messy, but it works.
#
IFS=$IFSNL
for FNAME in `cat "${RKH_FILEPROP_LIST}"`; do
test ! -f "${FNAME}" -a ! -h "${FNAME}" && continue
FDATA=""
SYSLNK=""
SYSHASH=""
PKGNAME=""
FNAMEGREP=""
RPM_QUERY_RESULT=""
SYSLNK_CC=0
NOVRFYFILE=0
COLON_COUNT=0
FILE_IS_PKGD=0
DEPENDENCY_ERR=0
IFS=$RKHIFS
PROP_FILE_LIST_COUNT=`expr ${PROP_FILE_LIST_COUNT} + 1`
#
# Set up some variables here based on the file name. We will
# need them later on.
#
COLON_COUNT=`echo "${FNAME}" | tr -c -d ':' | wc -c | tr -d ' '`
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
#
# Test to see if we are looking for specific files or not.
#
if [ -n "${PROPUPD_OPT}" ]; then
#
# If we are looking for specific files, then just copy the
# entries from the current rkhunter.dat file for the files
# we aren't looking for. For the ones we do want, we fall
# through and process them as before.
#
if [ $NODATFILE -eq 0 ]; then
if [ -z "`echo \"${PROPUPD_OPT}\" | grep \"^${FNAMEGREP}$\"`" ]; then
if [ $OLD_FMTVERSION -eq 0 ]; then
RKHTMPVAR=`grep "^File:${FNAMEGREP}:" "${RKHDAT_FILE}"`
else
RKHTMPVAR=`grep "^File:${COLON_COUNT}:${FNAMEGREP}:" "${RKHDAT_FILE}"`
fi
if [ -n "${RKHTMPVAR}" ]; then
echo "${RKHTMPVAR}" >>"${RKHDAT_TMPFILE}"
IFS=$IFSNL
continue
fi
fi
fi
PROP_FILE_PROPOPT_COUNT=`expr ${PROP_FILE_PROPOPT_COUNT} + 1`
fi
#
# Sort out the directory counters.
#
test -n "${DIRNAME_CMD}" && DIR=`${DIRNAME_CMD} "${FNAME}"` || DIR=`echo "${FNAME}" | sed -e 's:/[^/]*$::'`
RKHTMPVAR2=`echo "${DIR}" | sed -e 's/\./\\\./g'`
RKHTMPVAR=`echo "${DIR_FILE_COUNT}" | grep "^${RKHTMPVAR2}:"`
if [ -z "${RKHTMPVAR}" ]; then
DIR_FILE_COUNT="${DIR_FILE_COUNT}
${DIR}:1"
else
RKHTMPVAR=`echo ${RKHTMPVAR} | sed -e 's/^.*:\([0-9]*\)$/\1/'`
RKHTMPVAR=`expr ${RKHTMPVAR} + 1`
DIR_FILE_COUNT=`echo "${DIR_FILE_COUNT}" | sed -e "s;^\(${DIR}:\).*;\1${RKHTMPVAR};"`
fi
#
# See if the file is to be exempt from any package manager verification.
#
if [ -n "`echo \"${PKGMGRNOVRFY}\" | grep \"^${FNAMEGREP}$\"`" ]; then
NOVRFYFILE=1
fi
#
# Now start to get the file info by seeing if we are using a
# package manager. If we are, then get the package name and
# any other info we can except the hash value. That will be
# dealt with afterwards.
#
case "${PKGMGR}" in
RPM)
#
# First see if the file is exempt or belongs to a package.
#
if [ $NOVRFYFILE -eq 0 ]; then
RKHTMPVAR=`${RPM_CMD} -qf "${FNAME}" --queryformat '%{NAME}\n' 2>/dev/null`
ERRCODE=$?
if [ $ERRCODE -eq 0 ]; then
#
# Okay we have a package name.
#
FILE_IS_PKGD=1
PKGNAME=`echo "${RKHTMPVAR}" | tail ${TAIL_OPT}1`
RPM_QUERY_RESULT_ARCH=`${RPM_CMD} -qf --queryformat '[%{FILEMODES:octal}:%{FILEUSERNAME}:%{FILEGROUPNAME}:%{FILESIZES}:%{FILEMTIMES}:%{FILEMD5S}:%{ARCH}:%{FILELINKTOS}:%{FILENAMES}\n]' "${FNAME}" 2>/dev/null | grep ":${FNAMEGREP}\$"`
ERRCODE=$?
#
# The error code actually refers to the 'grep' command above. If the
# file is not found in the package, then this is probably due to the
# 'bin' directory being a link. So we change the filename, and retest.
#
if [ $ERRCODE -eq 1 -a $BINISLINK -eq 1 ]; then
if [ -n "`echo \"$FNAME\" | grep '^\/usr\/'`" ]; then
RKHTMPVAR3=`echo "$FNAMEGREP" | sed -e 's:^/usr::'`
else
RKHTMPVAR3="/usr${FNAMEGREP}"
fi
RPM_QUERY_RESULT_ARCH=`${RPM_CMD} -qf --queryformat '[%{FILEMODES:octal}:%{FILEUSERNAME}:%{FILEGROUPNAME}:%{FILESIZES}:%{FILEMTIMES}:%{FILEMD5S}:%{ARCH}:%{FILELINKTOS}:%{FILENAMES}\n]' "${FNAME}" 2>/dev/null | grep ":${RKHTMPVAR3}\$"`
ERRCODE=$?
fi
if [ $ERRCODE -eq 0 ]; then
#
# If multiple packages claim the same file, we
# use the last one in the list. However, if we
# have 64-bit as well as 32-bit packages, then
# we use the 64-bit package in preference (as
# this is what RPM does).
#
RPM_QUERY_RESULT=`echo "${RPM_QUERY_RESULT_ARCH}" | egrep ':(x86_64|ia64):' | tail ${TAIL_OPT}1`
test -z "${RPM_QUERY_RESULT}" && RPM_QUERY_RESULT=`echo "${RPM_QUERY_RESULT_ARCH}" | tail ${TAIL_OPT}1`
FPERM="0`echo \"${RPM_QUERY_RESULT}\" | cut -d: -f1 | cut -c 3-`"
FPERM=`echo "${FPERM}" | sed -e 's/^00/0/'`
RKHUID=`echo "${RPM_QUERY_RESULT}" | cut -d: -f2`
RKHUID=`grep "^${RKHUID}:" /etc/passwd 2>/dev/null | cut -d: -f3`
RKHGID=`echo "${RPM_QUERY_RESULT}" | cut -d: -f3`
RKHGID=`grep "^${RKHGID}:" /etc/group 2>/dev/null | cut -d: -f3`
RKHSIZE=`echo "${RPM_QUERY_RESULT}" | cut -d: -f4`
RKHDTM=`echo "${RPM_QUERY_RESULT}" | cut -d: -f5`
if [ -h "${FNAME}" ]; then
test -n "${DIRNAME_CMD}" && DIR=`${DIRNAME_CMD} "${FNAME}"` || DIR=`echo "${FNAME}" | sed -e 's:/[^/]*$::'`
SYSLNK=`echo "${RPM_QUERY_RESULT}" | cut -d: -f8`
SYSLNK="${DIR}/${SYSLNK}"
# This ensures the link target has things like '..' removed.
test $HAVE_READLINK -eq 1 && SYSLNK=`${READLINK_CMD} -f "${SYSLNK}"`
fi
#
# Now get the inode value directly from the disk,
# but only if prelinking is not being used.
#
RKHTMPVAR2=""
if [ $PRELINKED -eq 0 -a -n "${INODECMD}" ]; then
RKHTMPVAR2=`eval ${INODECMD} "\"${FNAME}\"" 2>/dev/null | tr -d ' '`
fi
FDATA="${RKHTMPVAR2}:${FPERM}:${RKHUID}:${RKHGID}:${RKHSIZE}:${RKHDTM}"
else
NOHASH_COUNT=`expr $NOHASH_COUNT + 1`
display --to LOG --type INFO CMD_ERROR "rpm -qf --queryformat... ${FNAME}" $ERRCODE
fi
fi
fi
;;
DPKG)
#
# First see if the file is exempt or part of a known package.
#
if [ $NOVRFYFILE -eq 1 ]; then
ERRCODE=1
else
RKHTMPVAR=`${DPKG_CMD} --search "${FNAME}" 2>/dev/null`
ERRCODE=$?
fi
if [ $ERRCODE -eq 0 ]; then
#
# Now we sort out the base part of the package name.
#
PKGNAME=`echo "${RKHTMPVAR}" | tail ${TAIL_OPT}1 | cut -d: -f1`
fi
;;
BSD)
#
# First see if the file is exempt or part of a known package.
#
if [ $NOVRFYFILE -eq 1 ]; then
ERRCODE=1
else
RKHTMPVAR=`${PKG_CMD} -F -e "${FNAME}" 2>/dev/null`
ERRCODE=$?
fi
if [ $ERRCODE -eq 0 ]; then
#
# Now we sort out the base part of the package name.
#
PKGNAME=`echo "${RKHTMPVAR}" | tail ${TAIL_OPT}1 | sed -e 's/[0-9]nb[0-9][0-9]*$//; s/-[0-9.]*$//'`
fi
;;
SOLARIS)
#
# First see if the file is exempt or belongs to a package.
#
if [ $NOVRFYFILE -eq 1 ]; then
ERRCODE=1
else
RKHTMPVAR=`grep "^${FNAMEGREP} " /var/sadm/install/contents 2>/dev/null`
test -n "${RKHTMPVAR}" && ERRCODE=0 || ERRCODE=1
fi
if [ $ERRCODE -eq 0 ]; then
#
# Okay we have a package name.
#
PKGNAME=`echo "${RKHTMPVAR}" | cut -d' ' -f10-`
FPERM=`echo "${RKHTMPVAR}" | cut -d' ' -f4`
RKHUID=`echo "${RKHTMPVAR}" | cut -d' ' -f5`
RKHUID=`grep "^${RKHUID}:" /etc/passwd 2>/dev/null | cut -d: -f3`
RKHGID=`echo "${RKHTMPVAR}" | cut -d' ' -f6`
RKHGID=`grep "^${RKHGID}:" /etc/group 2>/dev/null | cut -d: -f3`
RKHSIZE=`echo "${RKHTMPVAR}" | cut -d' ' -f7`
if [ $USE_SUNSUM -eq 1 ]; then
# Treat this as a fully packaged file.
FILE_IS_PKGD=1
SYSHASH=`echo "${RKHTMPVAR}" | cut -d' ' -f8`
fi
RKHDTM=`echo "${RKHTMPVAR}" | cut -d' ' -f9`
#
# Now get the inode value.
#
RKHTMPVAR2=""
test -n "${INODECMD}" && RKHTMPVAR2=`eval ${INODECMD} "\"${FNAME}\"" 2>/dev/null | tr -d ' '`
FDATA="${RKHTMPVAR2}:${FPERM}:${RKHUID}:${RKHGID}:${RKHSIZE}:${RKHDTM}"
fi
;;
esac
if [ -n "${HASH_CMD}" ]; then
if [ -n "`echo \"${PRELINK_DEP_ERR_CMDS}\" | grep \" ${FNAMEGREP} \"`" ]; then
FILE_IS_PKGD=1
SYSHASH="ignore-prelink-dep-err"
display --to LOG --type INFO FILE_PROP_IGNORE_PRELINK_DEP_ERR "`name2text \"${FNAME}\"`"
else
case "${PKGMGR}" in
RPM)
test $FILE_IS_PKGD -eq 1 && SYSHASH=`echo "${RPM_QUERY_RESULT}" | cut -d: -f6`
;;
DPKG)
#
# If we have a package name, then strip off the leading
# '/' from the pathname, and then get the hash value.
#
if [ -n "${PKGNAME}" ]; then
if [ -f "/var/lib/dpkg/info/${PKGNAME}.md5sums" ]; then
FILNAM=`echo "${FNAME}" | sed -e 's:^/::; s:\.:\\\.:g'`
SYSHASH=`egrep "( |\./)${FILNAM}\$" "/var/lib/dpkg/info/${PKGNAME}.md5sums" 2>/dev/null | cut -d' ' -f1`
test -n "${SYSHASH}" && FILE_IS_PKGD=1
fi
fi
;;
BSD)
#
# If we have a package name, then strip off the leading
# '/usr/pkg' from the pathname, and then get the hash value.
#
if [ -n "${PKGNAME}" ]; then
FILNAM=`echo "${FNAME}" | sed -e 's:^/usr/pkg/::; s:\.:\\\.:g'`
SYSHASH=`${PKG_CMD} -v -L "${RKHTMPVAR}" 2>/dev/null | grep -A 1 "File: ${FILNAM}\$" | tail ${TAIL_OPT}1 | cut -d: -f3`
test -n "${SYSHASH}" && FILE_IS_PKGD=1
fi
;;
SOLARIS)
#
# If we are to use the stored 16-bit checksum, then
# SYSHASH will already have been set above. Otherwise,
# just calculate the hash as for non-packaged files.
#
;;
esac
fi
if [ $FILE_IS_PKGD -eq 0 ]; then
if [ "${HASH_CMD}" != "NONE" ]; then
SYSHASH=""
RKHTMPVAR=`${HASH_CMD} "${FNAME}" 2>&1`
if [ -n "`echo \"${RKHTMPVAR}\" | egrep 'prelink.* (dependenc|adjusting unfinished)'`" ]; then
DEPENDENCY_ERR=1
RKHTMPVAR=`echo "${RKHTMPVAR}" | tr '\n' ':' | sed -e 's/:$//'`
else
SYSHASH=`echo "${RKHTMPVAR}" | cut -d' ' -f $HASH_FLD_IDX | grep '^[0-9a-fA-F]*$'`
fi
fi
if [ -z "${SYSHASH}" ]; then
if [ "${HASH_CMD}" = "NONE" ]; then
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type INFO FILE_PROP_NO_PKGMGR_FILE "`name2text \"${FNAME}\"`"
fi
elif [ -h "${FNAME}" -a ! -e "${FNAME}" ]; then
if [ $HAVE_READLINK -eq 1 ]; then
SYSLNK=`${READLINK_CMD} -f "${FNAME}"`
RKHTMPVAR="${SYSLNK}"
RKHTMPVAR2=`echo "${SYSLNK}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
else
RKHTMPVAR=""
fi
# Check the link target to see if it is whitelisted.
if [ $HAVE_READLINK -eq 1 -a -n "`echo \"${EXISTWHITELIST}\" | grep \"^${RKHTMPVAR2}$\"`" ]; then
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type INFO FILE_PROP_BROKEN_LINK_WL_TGT "`name2text \"${FNAME}\"`" "`name2text \"${RKHTMPVAR}\"`"
fi
else
# Treat a broken link simply as a file with no hash.
BROKEN_LINK_COUNT=`expr ${BROKEN_LINK_COUNT} + 1`
display --to LOG --type WARNING FILE_PROP_NO_SYSHASH "`name2text \"${FNAME}\"`"
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_NO_SYSHASH_BL "`name2text \"${FNAME}\"`" "`name2text \"${RKHTMPVAR}\"`"
fi
else
NOHASH_COUNT=`expr ${NOHASH_COUNT} + 1`
display --to LOG --type WARNING FILE_PROP_NO_SYSHASH "`name2text \"${FNAME}\"`"
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_NO_SYSHASH_CMD "${RKHTMPVAR}"
if [ $DEPENDENCY_ERR -eq 1 ]; then
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_NO_SYSHASH_DEPENDENCY "`name2text \"${FNAME}\"`"
fi
fi
fi
fi
fi
if [ -h "${FNAME}" -a -z "${SYSLNK}" ]; then
test $HAVE_READLINK -eq 1 && SYSLNK=`${READLINK_CMD} -f "${FNAME}"`
fi
if [ -z "${SCMD}" ]; then
FDATA=":::::"
else
if [ -z "${FDATA}" ]; then
FDATA=`eval ${SCMD} "\"${FNAME}\"" 2>/dev/null | tr ' ' ':' | sed -e 's/:$//'`
if [ -z "${FDATA}" ]; then
FDATA=":::::"
elif [ -n "`echo ${FDATA} | grep '^[^:]*:0[0-9][0-9][0-9][0-9]:'`" ]; then
# Ensure the file permissions consist of only 4 digits.
FDATA=`echo $FDATA | sed -e 's/^\([^:]*:\)0\(.*\)$/\1\2/'`
fi
fi
fi
# Check if the symbolic link has any colon characters in it.
SYSLNK_CC=`echo "${SYSLNK}" | tr -c -d ':' | wc -c | tr -d ' '`
echo "File:${COLON_COUNT}:${FNAME}:${SYSHASH}:${FDATA}:${PKGNAME}:${SYSLNK_CC}:${SYSLNK}:" >>"${RKHDAT_TMPFILE}"
IFS=$IFSNL
done
IFS=$RKHIFS
#
# Display the number of files found in the directories.
#
for DIR in ${DIR_FILE_COUNT}; do
test -z "${DIR}" && continue
RKHTMPVAR=`echo $DIR | cut -d: -f1`
RKHTMPVAR2=`echo $DIR | cut -d: -f2`
display --to LOG --type INFO SET_FILE_PROP_DIR_FILE_COUNT $RKHTMPVAR2 "${RKHTMPVAR}"
done
#
# Finally put the new file in place.
#
if [ -f "${RKHDAT_FILE}" ]; then
RKHTMPVAR="updated"
else
RKHTMPVAR="created"
fi
test $NOHASH_COUNT -gt 0 -o $BROKEN_LINK_COUNT -gt 0 && RET_CODE=1
# Don't display messages if this is an automatic update.
if [ $OS_CHANGED -eq 1 -a $UPDT_ON_OS_CHANGE -eq 1 ]; then
:
else
if [ $NOHASH_COUNT -eq 0 ]; then
if [ $BROKEN_LINK_COUNT -eq 0 ]; then
if [ -n "${PROPUPD_OPT}" ]; then
display --to SCREEN+LOG --type INFO SET_FILE_PROP_FILE_COUNT_PROPOPT "${RKHTMPVAR}" $PROP_FILE_LIST_TOTAL $PROP_FILE_PROPOPT_COUNT $PROP_FILE_LIST_COUNT
else
display --to SCREEN+LOG --type INFO SET_FILE_PROP_FILE_COUNT "${RKHTMPVAR}" $PROP_FILE_LIST_TOTAL $PROP_FILE_LIST_COUNT
fi
else
if [ -n "${PROPUPD_OPT}" ]; then
display --to SCREEN+LOG --type INFO SET_FILE_PROP_FILE_COUNT_PROPOPT_BL "${RKHTMPVAR}" $PROP_FILE_LIST_TOTAL $PROP_FILE_PROPOPT_COUNT $PROP_FILE_LIST_COUNT $BROKEN_LINK_COUNT
else
display --to SCREEN+LOG --type INFO SET_FILE_PROP_FILE_COUNT_BL "${RKHTMPVAR}" $PROP_FILE_LIST_TOTAL $PROP_FILE_LIST_COUNT $BROKEN_LINK_COUNT
fi
fi
else
if [ $BROKEN_LINK_COUNT -eq 0 ]; then
if [ -n "${PROPUPD_OPT}" ]; then
display --to SCREEN+LOG --type INFO SET_FILE_PROP_FILE_COUNT_NOHASH_PROPOPT "${RKHTMPVAR}" $PROP_FILE_LIST_TOTAL $PROP_FILE_PROPOPT_COUNT $PROP_FILE_LIST_COUNT $NOHASH_COUNT
else
display --to SCREEN+LOG --type INFO SET_FILE_PROP_FILE_COUNT_NOHASH "${RKHTMPVAR}" $PROP_FILE_LIST_TOTAL $PROP_FILE_LIST_COUNT $NOHASH_COUNT
fi
else
if [ -n "${PROPUPD_OPT}" ]; then
display --to SCREEN+LOG --type INFO SET_FILE_PROP_FILE_COUNT_NOHASH_PROPOPT_BL "${RKHTMPVAR}" $PROP_FILE_LIST_TOTAL $PROP_FILE_PROPOPT_COUNT $PROP_FILE_LIST_COUNT $NOHASH_COUNT $BROKEN_LINK_COUNT
else
display --to SCREEN+LOG --type INFO SET_FILE_PROP_FILE_COUNT_NOHASH_BL "${RKHTMPVAR}" $PROP_FILE_LIST_TOTAL $PROP_FILE_LIST_COUNT $NOHASH_COUNT $BROKEN_LINK_COUNT
fi
fi
fi
fi
return
}
create_rkh_file_prop_list() {
#
# This function creates the file of pathnames
# used for the file properties check.
#
get_temp_file "${RKHTMPDIR}/rkh_prop_list.new"
touch "${TEMPFILE}"
IFS=$IFSNL
for DIR in ${PROP_DIR_LIST}; do
for FNAME in ${PROP_FILE_LIST}; do
echo "${DIR}/${FNAME}" >>"${TEMPFILE}"
done
done
#
# Now we add any user specified absolute
# pathnames to be included in the list.
#
if [ -n "${USER_FILE_LIST}" ]; then
for FNAME in ${USER_FILE_LIST}; do
#
# We must exclude any user requested files or directories.
#
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -n "${USER_EXCLUDE_PROP}" ]; then
test -n "`echo \"${USER_EXCLUDE_PROP}\" | grep \"^${FNAMEGREP}$\"`" && continue
fi
test -z "`grep \"^${FNAMEGREP}$\" "${TEMPFILE}" 2>/dev/null`" && echo "${FNAME}" >>"${TEMPFILE}"
done
fi
IFS=$RKHIFS
cp -f "${TEMPFILE}" "${RKH_FILEPROP_LIST}" >/dev/null 2>&1
chmod 640 "${RKH_FILEPROP_LIST}" >/dev/null 2>&1
rm -f "${TEMPFILE}" >/dev/null 2>&1
return
}
get_old_prop_attrs() {
#
# This function simply determines some of the attributes
# used when the file properties database was created.
#
FNAME=$1
test -z "${FNAME}" -o ! -f "${FNAME}" && return
if [ -s "${FNAME}" ]; then
OLD_HASH_FUNC=`grep '^Hash:' "${FNAME}" | cut -d: -f2-`
OLD_PKGMGR=`grep '^Pkgmgr:' "${FNAME}" | cut -d: -f2`
OLD_ATTRUPD=`grep '^Attributes:' "${FNAME}" | cut -d: -f2`
fi
return
}
do_prop_update() {
#
# This function updates the local hosts rkhunter.dat file
# with O/S information and file properties.
#
display --to LOG --type INFO --nl PROPUPD_START
#
# First we need to get a temporary file name to use.
#
get_temp_file "${RKHTMPDIR}/rkhunter.dat"
RKHDAT_TMPFILE="${TEMPFILE}"
touch "${RKHDAT_TMPFILE}"
display --to LOG --type INFO CREATED_TEMP_FILE "${RKHDAT_TMPFILE}"
#
# We now start to write out information about this system
# to the file. Some information we already have available,
# but for others we call functions to obtain what is wanted.
#
rkh_dat_set_version
display --to LOG --type PLAIN PROPUPD_OSINFO_START
rkh_dat_get_os_info
echo "Host:${HOST_NAME}" >>"${RKHDAT_TMPFILE}"
if [ -n "${ARCH}" ]; then
echo "Arch:${ARCH}" >>"${RKHDAT_TMPFILE}"
display --to LOG --type INFO PROPUPD_ARCH_FOUND "${ARCH}"
fi
if [ -n "${RELEASE}" ]; then
display --to LOG --type INFO PROPUPD_REL_FILE "${RELEASE}"
else
display --to LOG --type INFO PROPUPD_NO_REL_FILE
display --to LOG --type PLAIN NAME " `ls -ld /etc/*release* /etc/*version* 2>/dev/null | tr '\n' ' '`"
fi
if [ -n "${OSNAME}" ]; then
echo "OS:${OSNAME}" >>"${RKHDAT_TMPFILE}"
display --to LOG --type INFO PROPUPD_OSNAME_FOUND "${OSNAME}"
fi
if [ $PRELINKED -eq 0 ]; then
echo "Prelinked:No" >>"${RKHDAT_TMPFILE}"
else
echo "Prelinked:Yes" >>"${RKHDAT_TMPFILE}"
fi
#
# We do not want to bother storing the file hashes or other attibutes
# if the user has disabled these tests permanently. However, to do
# this we must check whether the relevant test is enabled or not, and
# that the --enable/--disable command-line options have not been used.
#
if ! `check_test hashes` && test $ENDIS_OPT -eq 0; then
echo "Hash:Disabled" >>"${RKHDAT_TMPFILE}"
elif [ -n "${PRELINK_HASH}" ]; then
echo "Hash:${PRELINK_HASH}" >>"${RKHDAT_TMPFILE}"
else
echo "Hash:${HASH_FUNC}" >>"${RKHDAT_TMPFILE}"
fi
echo "Pkgmgr:${PKGMGR}" >>"${RKHDAT_TMPFILE}"
if ! `check_test attributes` && test $ENDIS_OPT -eq 0; then
echo "Attributes:Disabled" >>"${RKHDAT_TMPFILE}"
elif [ -z "${STAT_CMD}" ]; then
echo "Attributes:Nostatcmd" >>"${RKHDAT_TMPFILE}"
else
echo "Attributes:Stored" >>"${RKHDAT_TMPFILE}"
fi
echo "FormatVersion:1" >>"${RKHDAT_TMPFILE}"
#
# Before we get the actual file properties we need
# to write out the current list of pathnames.
#
create_rkh_file_prop_list
#
# Next get the file properties.
#
rkh_dat_set_file_properties
#
# We now need to record the hash function and
# package manager as if they were the old values.
#
get_old_prop_attrs "${RKHDAT_TMPFILE}"
#
# Now put the new rkhunter.dat file in place.
#
cp -f -p "${RKHDAT_FILE}" "${RKHDAT_FILE}.old" >/dev/null 2>&1
cp -f "${RKHDAT_TMPFILE}" "${RKHDAT_FILE}" >/dev/null 2>&1
ERRCODE=$?
if [ $ERRCODE -ne 0 ]; then
RET_CODE=1
display --to LOG --type INFO CMD_ERROR "cp ${RKHDAT_TMPFILE} ${RKHDAT_FILE}" $ERRCODE
display --to SCREEN+LOG --type WARNING PROPUPD_ERROR $ERRCODE
else
display --to LOG --type INFO PROPUPD_NEW_DAT_FILE "${DB_PATH}"
fi
chmod 640 "${RKHDAT_FILE}" >/dev/null 2>&1
rm -f "${RKHDAT_TMPFILE}" >/dev/null 2>&1
return
}
get_next_mirror() {
#
# This function will obtain the next mirror in the mirrors file
# if no mirror is currently being used. It then optionally
# rotates the mirrors in the file.
#
#
# Return if there is no mirrors file.
#
if [ ! -f "${DB_PATH}/mirrors.dat" ]; then
display --to LOG --type INFO MIRRORS_NO_FILE "${DB_PATH}/mirrors.dat"
return
fi
#
# Return if there are no defined mirrors.
#
case $MIRRORS_MODE in
0)
MIRROR=`egrep -i '^(local|remote|mirror)=' "${DB_PATH}/mirrors.dat" | head ${HEAD_OPT}1`
;;
1)
MIRROR=`grep -i '^local=' "${DB_PATH}/mirrors.dat" | head ${HEAD_OPT}1`
;;
2)
MIRROR=`grep -i '^remote=' "${DB_PATH}/mirrors.dat" | head ${HEAD_OPT}1`
;;
esac
if [ -z "${MIRROR}" ]; then
display --to LOG --type INFO MIRRORS_NO_MIRRORS "${DB_PATH}/mirrors.dat"
return
fi
#
# If we are not rotating the mirrors, then we need to calculate
# which one to use next in the list. Return when we have done that.
#
if [ $ROTATE_MIRRORS -eq 0 ]; then
N=`expr $TOTAL_MIRRORS - $MIRROR_COUNT`
case $MIRRORS_MODE in
0)
MIRROR=`egrep -i '^(local|remote|mirror)=' "${DB_PATH}/mirrors.dat" | head ${HEAD_OPT}$N | tail ${TAIL_OPT}1 | cut -d= -f2-`
;;
1)
MIRROR=`grep -i '^local=' "${DB_PATH}/mirrors.dat" | head ${HEAD_OPT}$N | tail ${TAIL_OPT}1 | cut -d= -f2-`
;;
2)
MIRROR=`grep -i '^remote=' "${DB_PATH}/mirrors.dat" | head ${HEAD_OPT}$N | tail ${TAIL_OPT}1 | cut -d= -f2-`
;;
esac
return
fi
#
# Now get the version number of the mirrors file. If the version
# does not exist or is corrupt, then we reset it to zero. This
# then allows the file to be updated next time the '--update'
# option is used.
#
MIRRORSVERSION=`grep '^[Vv]ersion:[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$' "${DB_PATH}/mirrors.dat" | tail ${TAIL_OPT}1`
if [ -z "${MIRRORSVERSION}" ]; then
display --to LOG --type INFO MIRRORS_NO_VERSION "${DB_PATH}/mirrors.dat"
MIRRORSVERSION="Version:0000000000"
fi
#
# Next get the remaining mirrors.
#
OTHERMIRRORS=`egrep -i '^(local|remote|mirror)=' "${DB_PATH}/mirrors.dat" | grep -v "^${MIRROR}\$"`
#
# We need to get a temporary file name to use.
#
get_temp_file "${RKHTMPDIR}/mirrors.dat"
MIRRORS_FILE="${TEMPFILE}"
touch "${MIRRORS_FILE}"
display --to LOG --type INFO CREATED_TEMP_FILE "${MIRRORS_FILE}"
#
# Output to the temporary file the mirrors version, the other
# mirrors, and finally the mirror we are about to use.
#
echo "${MIRRORSVERSION}" >"${MIRRORS_FILE}"
for RKHM in ${OTHERMIRRORS}; do
echo "${RKHM}" >>"${MIRRORS_FILE}"
done;
echo "${MIRROR}" >>"${MIRRORS_FILE}"
MIRROR=`echo "${MIRROR}" | cut -d= -f2-`
#
# Move the new file into place, and delete the temporary file.
#
cat "${MIRRORS_FILE}" >"${DB_PATH}/mirrors.dat"
rm -f "${MIRRORS_FILE}" >/dev/null 2>&1
display --to LOG --type INFO MIRRORS_ROTATED "${DB_PATH}/mirrors.dat"
return
}
download_file() {
#
# This function downloads a specified file. It takes three parameters:
# 1=mirror, 2=url, 3=output file
#
# The URL is just the filename portion. The user will supply the
# full URL, less the filename, to where the files are stored on
# the local or remote server. For the SourceForge mirrors we will
# provide the URL.
#
# The function sets a return code (DNLOADERR).
#
#
# We loop round through the mirrors until the file is downloaded.
# We do this by first seeing how many mirrors are available. Then
# we call a function to get the next mirror, which also rotates
# the mirror file. If a mirror has already been set, then that
# mirror is used. That way, in effect, once we find a good mirror
# then it will be used for all the downloads.
#
MIRROR=$1
URL=$2
OUTPUT_FILE=$3
DNLOADERR=0
MIRROR_COUNT=0
TOTAL_MIRRORS=0
if [ -f "${DB_PATH}/mirrors.dat" ]; then
#
# The version check will use both the
# SF mirrors and remote mirrors.
#
case $MIRRORS_MODE in
0)
MIRROR_COUNT=`egrep -i '^(local|remote|mirror)=' "${DB_PATH}/mirrors.dat" | wc -l | tr -d ' '`
;;
1)
MIRROR_COUNT=`grep -i '^local=' "${DB_PATH}/mirrors.dat" | wc -l | tr -d ' '`
;;
2)
MIRROR_COUNT=`grep -i '^remote=' "${DB_PATH}/mirrors.dat" | wc -l | tr -d ' '`
;;
esac
test -z "${MIRROR_COUNT}" && MIRROR_COUNT=0
fi
test $MIRROR_COUNT -eq 0 && MIRROR_COUNT=1
TOTAL_MIRRORS=$MIRROR_COUNT
while test $MIRROR_COUNT -gt 0; do
MIRROR_COUNT=`expr $MIRROR_COUNT - 1`
if [ -z "${MIRROR}" ]; then
get_next_mirror
if [ -z "${MIRROR}" ]; then
if [ $MIRRORS_MODE -eq 0 ]; then
MIRROR="http://rkhunter.sourceforge.net"
display --to LOG --type INFO MIRRORS_SF_DEFAULT "${MIRROR}"
else
DNLOADERR=1
break
fi
fi
#
# For the SF mirrors add on the final
# part of the mirror URL.
#
if [ "${MIRROR}" = "http://rkhunter.sourceforge.net" ]; then
MIRROR="${MIRROR}/1.3"
fi
fi
#
# Now we can download the data into the temporary file.
#
# uns - WGET_CMD (cmd, version tested, comments):
# wget, *, none.
# bget, 1.2, appends output.
# curl, 7.15.3: none.
# links/elinks, 0.4.2, decompresses output.
# lynx, 2.8.5dev.7, decompresses output.
CMD=""
DNLOADERR=0
rm -f "${OUTPUT_FILE}" >/dev/null 2>&1
case "${RKHWEBCMD_BASE}" in
wget)
CMD="${RKHWEBCMD} ${RKHWEBCMD_OPTS} -q -O \"${OUTPUT_FILE}\" ${MIRROR}${URL} 2>/dev/null"
;;
curl)
CMD="${RKHWEBCMD} ${RKHWEBCMD_OPTS} --fail --output \"${OUTPUT_FILE}\" ${MIRROR}${URL} 2>/dev/null"
;;
bget)
CMD="${RKHWEBCMD} ${RKHWEBCMD_OPTS} --out \"${OUTPUT_FILE}\" ${MIRROR}${URL} 2>/dev/null"
;;
links|elinks)
CMD="${RKHWEBCMD} ${RKHWEBCMD_OPTS} -no-home 1 -source ${MIRROR}${URL} >\"${OUTPUT_FILE}\" 2>/dev/null"
;;
lynx)
CMD="${RKHWEBCMD} ${RKHWEBCMD_OPTS} -source ${MIRROR}${URL} >\"${OUTPUT_FILE}\" 2>/dev/null"
;;
GET)
CMD="${RKHWEBCMD} ${RKHWEBCMD_OPTS} ${MIRROR}${URL} >\"${OUTPUT_FILE}\" 2>/dev/null"
;;
*)
CMD="${RKHWEBCMD} ${RKHWEBCMD_OPTS} ${MIRROR}${URL} >\"${OUTPUT_FILE}\" 2>/dev/null"
;;
esac
display --to LOG --type INFO DOWNLOAD_CMD "${CMD}"
eval ${CMD}
DNLOADERR=$?
test $DNLOADERR -gt 1 && DNLOADERR=1
#
# Some of these commands do not set the return code. As such we
# need to look in the output file to see if an error occurred.
#
if [ $DNLOADERR -eq 0 ]; then
if [ -n "`echo \"${URL}\" | grep '/i18n\.ver$'`" ]; then
#
# The i18n.ver file is of a different
# format from the other files.
#
:
elif [ -n "`echo \"${URL}\" | grep '/rkhunter_latest\.dat$'`" ]; then
#
# The versioncheck file should just be a version number.
#
if [ -z "`grep '^[0-9][0-9]*\.[0-9][.0-9]*$' \"${OUTPUT_FILE}\"`" ]; then
DNLOADERR=1
fi
else
#
# All other files should have a normal
# version number as the first line in them.
#
if [ -z "`grep '^[Vv]ersion:[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$' \"${OUTPUT_FILE}\"`" ]; then
DNLOADERR=1
fi
fi
fi
test ! -s "${OUTPUT_FILE}" && DNLOADERR=1
if [ $DNLOADERR -eq 0 ]; then
break
elif [ $MIRROR_COUNT -gt 0 ]; then
MIRROR=""
display --to LOG --type INFO DOWNLOAD_FAIL $MIRROR_COUNT
fi
done
return $DNLOADERR
}
do_i18n_update() {
#
# This function updates the i18n language files.
#
# We do not know which i18n files should be checked until we
# have downloaded the i18n/i18n.ver file. This file will tell
# us which i18n files are available, and their latest version
# number. We loop through the files, and check each version
# number against the installed file.
#
download_file "${MIRROR}" "/i18n/${PROGRAM_version}/i18n.ver" "${RKHUPD_FILE}"
ERRCODE=$?
if [ $ERRCODE -eq 0 ]; then
#
# Check that we have some version numbers. There
# should always be at least one, for the English
# language! Once we have the list of files, we can
# remove the temporary file and re-use it when
# downloading the language files.
#
FOUNDFILES=`grep '^[a-zA-Z][a-zA-Z0-9._-]*:[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$' "${RKHUPD_FILE}"`
rm -f "${RKHUPD_FILE}" >/dev/null 2>&1
if [ -z "${FOUNDFILES}" ]; then
RET_CODE=1
UPD_ERROR=1
display --to SCREEN+LOG --type PLAIN --screen-indent 2 --color RED --result UPD_FAILED UPDATE_CHECKING_FILE 'i18n versions'
display --to LOG --type WARNING UPDATE_I18N_NO_VERS
return
fi
#
# Now loop through the language files checking their
# version numbers.
#
for FNAME in ${FOUNDFILES}; do
LANGFILE=`echo "${FNAME}" | cut -d: -f1`
LATEST_VERS=`echo "${FNAME}" | cut -d: -f2`
#
# Only update the language files the user has asked for.
#
if [ -n "${UPDATE_LANG}" ]; then
if [ -z "`echo \" ${UPDATE_LANG} \" | grep \" ${LANGFILE} \"`" ]; then
display --to LOG --type INFO UPDATE_SKIPPED
display --to SCREEN+LOG --type PLAIN --screen-indent 2 --color YELLOW --result SKIPPED UPDATE_CHECKING_FILE "i18n/${LANGFILE}"
continue
fi
fi
if [ -s "${DB_PATH}/i18n/${LANGFILE}" ]; then
PROG_VERS=`grep ${GREP_OPT} '^[Vv]ersion:[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$' "${DB_PATH}/i18n/${LANGFILE}" 2>/dev/null | tail ${TAIL_OPT}1 | cut -d: -f2`
if [ -z "${PROG_VERS}" ]; then
PROG_VERS=0
display --to LOG --type INFO UPDATE_FILE_NO_VERS "${DB_PATH}/i18n/${LANGFILE}"
fi
else
PROG_VERS=0
touch "${DB_PATH}/i18n/${LANGFILE}" >/dev/null 2>&1
chmod 640 "${DB_PATH}/i18n/${LANGFILE}" >/dev/null 2>&1
display --to LOG --type INFO UPDATE_FILE_MISSING "${DB_PATH}/i18n/${LANGFILE}"
fi
display --to LOG --type INFO VERSIONCHECK_CURRENT "${PROG_VERS}"
display --to LOG --type INFO VERSIONCHECK_LATEST "${LATEST_VERS}"
if [ $PROG_VERS -lt $LATEST_VERS ]; then
download_file "${MIRROR}" "/i18n/${PROGRAM_version}/${LANGFILE}" "${RKHUPD_FILE}"
ERRCODE=$?
if [ $ERRCODE -eq 0 ]; then
test $RET_CODE -eq 0 && RET_CODE=2
cat "${RKHUPD_FILE}" >"${DB_PATH}/i18n/${LANGFILE}"
display --to LOG --type INFO VERSIONCHECK_UPDT_AVAIL
display --to SCREEN+LOG --type PLAIN --screen-indent 2 --color GREEN --result UPD UPDATE_CHECKING_FILE "i18n/${LANGFILE}"
else
RET_CODE=1
UPD_ERROR=1
display --to LOG --type WARNING UPDATE_DOWNLOAD_FAIL "i18n/${LANGFILE}"
display --to SCREEN+LOG --type PLAIN --screen-indent 2 --color RED --result UPD_FAILED UPDATE_CHECKING_FILE "i18n/${LANGFILE}"
fi
rm -f "${RKHUPD_FILE}" >/dev/null 2>&1
else
display --to SCREEN+LOG --type PLAIN --screen-indent 2 --color GREEN --result NO_UPD UPDATE_CHECKING_FILE "i18n/${LANGFILE}"
fi
done
else
RET_CODE=1
UPD_ERROR=1
display --to SCREEN+LOG --type PLAIN --screen-indent 2 --color RED --result UPD_FAILED UPDATE_CHECKING_FILE 'i18n versions'
display --to LOG --type WARNING UPDATE_DOWNLOAD_FAIL 'i18n.ver'
fi
rm -f "${RKHUPD_FILE}" >/dev/null 2>&1
return
}
do_update() {
#
# This function checks to see if any of the supplied RKH
# *.dat and i18n files needs updating. If it does, then the
# file is overwritten with the new version.
#
display --to SCREEN+LOG --type PLAIN --color YELLOW --nl UPDATE_START
#
# First we need to get a temporary file name to use.
#
get_temp_file "${RKHTMPDIR}/rkhunter.upd"
RKHUPD_FILE="${TEMPFILE}"
touch "${RKHUPD_FILE}"
display --to LOG --type INFO CREATED_TEMP_FILE "${RKHUPD_FILE}"
#
# Now we loop round through the files we need to check. Each file
# will use the first mirror, and if necessary loop through the
# remaining mirrors until the file is downloaded. In theory this
# could take some time if the mirror sites are all experiencing
# problems and this is affecting all the files.
#
# For each file we look at the current version number. If there
# is a problem doing this, then we just try and download a new
# copy of the file. If the version number is okay, then we
# download the file to find the latest version number. If
# that is successful, we then update the file if necessary.
#
UPD_ERROR=0
MIRROR=""
for UPDFILE in mirrors.dat programs_bad.dat backdoorports.dat suspscan.dat; do
if [ $UPDATE_MIRRORS -eq 0 -a "${UPDFILE}" = "mirrors.dat" ]; then
display --to SCREEN+LOG --type PLAIN --screen-indent 2 --color GREEN --result SKIPPED UPDATE_CHECKING_FILE "${UPDFILE}"
continue
fi
LATEST_VERS=0
if [ -s "${DB_PATH}/${UPDFILE}" ]; then
PROG_VERS=`grep '^[Vv]ersion:[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$' "${DB_PATH}/${UPDFILE}" | tail ${TAIL_OPT}1 | cut -d: -f2`
if [ -z "${PROG_VERS}" ]; then
PROG_VERS=0
display --to LOG --type INFO UPDATE_FILE_NO_VERS "${UPDFILE}"
fi
else
PROG_VERS=0
touch "${DB_PATH}/${UPDFILE}" >/dev/null 2>&1
chmod 640 "${DB_PATH}/${UPDFILE}" >/dev/null 2>&1
display --to LOG --type INFO UPDATE_FILE_MISSING "${UPDFILE}"
fi
#
# Now download the file.
#
# Note: To avoid any backward incompatability we
# get the files from a specific directory which
# previous versions do not use.
#
download_file "${MIRROR}" "/${UPDFILE}" "${RKHUPD_FILE}"
ERRCODE=$?
#
# Next we compare the current and downloaded
# file version numbers.
#
if [ $ERRCODE -eq 0 ]; then
LATEST_VERS=`grep '^[Vv]ersion:[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$' "${RKHUPD_FILE}" | tail ${TAIL_OPT}1 | cut -d: -f2`
if [ -z "${LATEST_VERS}" ]; then
LATEST_VERS=0
elif [ -z "`echo \"${LATEST_VERS}\" | grep '^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$'`" ]; then
LATEST_VERS=0
fi
display --to LOG --type INFO VERSIONCHECK_CURRENT "${PROG_VERS}"
display --to LOG --type INFO VERSIONCHECK_LATEST "${LATEST_VERS}"
if [ $LATEST_VERS -eq 0 ]; then
RET_CODE=1
UPD_ERROR=1
display --to SCREEN+LOG --type PLAIN --screen-indent 2 --color RED --result VCHK_FAILED UPDATE_CHECKING_FILE "${UPDFILE}"
LATEST_VERS=`head ${HEAD_OPT}1 ${RKHUPD_FILE}`
display --to LOG --type WARNING VERSIONCHECK_CONV_FAIL "${PROG_VERS}" "${LATEST_VERS}"
elif [ $PROG_VERS -lt $LATEST_VERS ]; then
test $RET_CODE -eq 0 && RET_CODE=2
display --to LOG --type INFO VERSIONCHECK_UPDT_AVAIL
cat "${RKHUPD_FILE}" >"${DB_PATH}/${UPDFILE}"
display --to SCREEN+LOG --type PLAIN --screen-indent 2 --color GREEN --result UPD UPDATE_CHECKING_FILE "${UPDFILE}"
else
display --to SCREEN+LOG --type PLAIN --screen-indent 2 --color GREEN --result NO_UPD UPDATE_CHECKING_FILE "${UPDFILE}"
fi
else
RET_CODE=1
UPD_ERROR=1
display --to LOG --type WARNING UPDATE_DOWNLOAD_FAIL "${UPDFILE}"
display --to SCREEN+LOG --type PLAIN --screen-indent 2 --color RED --result UPD_FAILED UPDATE_CHECKING_FILE "${UPDFILE}"
fi
rm -f "${RKHUPD_FILE}" >/dev/null 2>&1
done
#
# We now need to update the i18n files. Since this is a little
# more complicated, it is handled in a separate function.
#
do_i18n_update
if [ $UPD_ERROR -eq 1 ]; then
if [ $NOLOG -eq 1 ]; then
display --to SCREEN --type PLAIN --nl --nl-after CHECK_WARNINGS_FOUND_RERUN
else
display --to SCREEN --type PLAIN --nl --nl-after CHECK_WARNINGS_FOUND_CHK_LOG "${RKHLOGFILE}"
fi
fi
return
}
do_versioncheck() {
#
# This function performs a program version check.
#
# It will set the return code in some instances:
# 0 - (implied) no error, no new version available
# 1 - a download (of the version number) error occurred
# 2 - no error occurred, but a new version is available
#
MIRROR=""
LATESTVERSION=""
display --to SCREEN+LOG --type PLAIN --color YELLOW --nl VERSIONCHECK_START
#
# First we need to get a temporary file name to use.
#
get_temp_file "${RKHTMPDIR}/rkhunter.vc"
RKHVC_FILE="${TEMPFILE}"
touch "${RKHVC_FILE}"
display --to LOG --type INFO CREATED_TEMP_FILE "${RKHVC_FILE}"
#
# Next we get the current program version number.
#
PROG_VERS=`echo "${PROGRAM_version}" | cut -d. -f1-3 | sed -e 's/\.\([0-9]\)\./.0\1./' | sed -e 's/\.\([0-9]\)$/.0\1/' | tr -d '.'`
test -z "${PROG_VERS}" && PROG_VERS=0
display --to SCREEN+LOG --type PLAIN --screen-indent 2 VERSIONCHECK_CURRENT "${PROGRAM_version}"
#
# Download the file, and then compare the current value
# with the downloaded one.
#
download_file "${MIRROR}" "/rkhunter_latest.dat" "${RKHVC_FILE}"
ERRCODE=$?
if [ $ERRCODE -eq 0 ]; then
LATESTVERSION=`cat "${RKHVC_FILE}" 2>/dev/null`
#
# Convert the version string to zero-spaced numbers.
# This allows us to numerically compare the versions,
# even when the numbers go above ten.
#
# E.g. '1.2.10' => 10210, '1.3.2' => 10302.
#
LATEST_VERS=`echo "${LATESTVERSION}" | cut -d. -f1-3 | sed -e 's/\.\([0-9]\)\./.0\1./' | sed -e 's/\.\([0-9]\)$/.0\1/' | tr -d '.'`
test -z "${LATEST_VERS}" && LATEST_VERS=0
display --to SCREEN+LOG --type PLAIN --screen-indent 2 VERSIONCHECK_LATEST "${LATESTVERSION}"
if [ $LATEST_VERS -eq 0 ]; then
RET_CODE=1
display --to SCREEN+LOG --type WARNING --screen-indent 2 VERSIONCHECK_CONV_FAIL "${PROGRAM_version}" "${LATESTVERSION}"
elif [ $PROG_VERS -lt $LATEST_VERS ]; then
test $RET_CODE -eq 0 && RET_CODE=2
display --to SCREEN+LOG --type PLAIN --screen-indent 2 VERSIONCHECK_UPDT_AVAIL
fi
else
RET_CODE=1
display --to LOG --type WARNING VERSIONCHECK_FAIL_ALL
display --to SCREEN+LOG --type PLAIN --screen-indent 2 VERSIONCHECK_LATEST_FAIL
fi
rm -f "${RKHVC_FILE}" >/dev/null 2>&1
return
}
do_config_file_check() {
#
# This function performs a basic configuration file check. Use of
# the configuration check command-line option will cause the known
# configured options to be checked as usual. So all we need to do
# here is look for any configuration options which are unknown.
#
#
# First we define the list of valid configuration options.
#
#
# All the following specified options should be single
# value options (that is, not any sort of list).
#
VALIDOPTS="${SPACE_LIST_OPTS} ${NEWLINE_LIST_OPTS}
ALLOW_SSH_PROT_V1 ALLOW_SSH_ROOT_USER ALLOW_SYSLOG_REMOTE_LOGGING APPEND_LOG
AUTO_X_DETECT COLOR_SET2 COPY_LOG_ON_ERROR DBDIR DISABLE_UNHIDE EPOCH_DATE_CMD
HASH_FLD_IDX HASH_FUNC HASH_CMD IMMUTABLE_SET INETD_CONF_PATH INSTALLDIR
LANGUAGE LOCK_TIMEOUT LOGFILE MAIL_CMD MIRRORS_MODE MODULES_DIR
OS_VERSION_FILE PASSWORD_FILE PHALANX2_DIRTEST PKGMGR ROOTDIR ROTATE_MIRRORS
SCAN_MODE_DEV SCRIPTDIR SHOW_LOCK_MSGS SHOW_SUMMARY_TIME SHOW_SUMMARY_WARNINGS_NUMBER
SSH_CONFIG_DIR SUSPSCAN_DEBUG SUSPSCAN_LINETHRESH SUSPSCAN_MAXSIZE SUSPSCAN_TEMP
SUSPSCAN_THRESH TMPDIR UPDATE_MIRRORS UPDT_ON_OS_CHANGE USE_SUNSUM USE_LOCKING
USE_SYSLOG WARN_ON_OS_CHANGE WEBCMD WEB_CMD WHITELISTED_IS_WHITE
XINETD_CONF_PATH"
VALIDOPTS=" `echo ${VALIDOPTS}` "
#
# Now check to see if any unknown options have been configured.
#
RKHTMPVAR=`egrep -h -v '^[ ]*(#|$)' ${CONFIGFILE} ${LOCALCONFIGFILE} ${LOCALCONFDIRFILES}`
IFS=$IFSNL
for CONFIGOPT in ${RKHTMPVAR}; do
CONFIGCMD=`echo ${CONFIGOPT} | cut -d= -f1`
#
# We have to handle the *_CMD entries specially because
# only certain commands are allowed to be replaced by
# a configuration option.
#
if [ -n "`echo ${CONFIGCMD} | grep '_CMD$'`" ]; then
case "${CONFIGCMD}" in
EPOCH_DATE_CMD|MAIL_CMD|WEB_CMD|HASH_CMD)
# We know about these ones.
;;
*)
# Dig out the actual command name used.
CFG_CMD=`echo ${CONFIGCMD} | sed -e 's/_CMD$//'`
# Check to see if the command is one we now about.
if [ -z "`echo \" ${CMDLIST} \" | grep -i \" ${CFG_CMD} \"`" ]; then
RET_CODE=1
echo "Unknown configuration file option: ${CONFIGOPT}"
fi
;;
esac
continue
fi
if [ -z "`echo \"${VALIDOPTS}\" | grep \" ${CONFIGCMD} \"`" ]; then
RET_CODE=1
echo "Unknown configuration file option: ${CONFIGOPT}"
fi
done
IFS=$RKHIFS
return
}
do_system_check_initialisation() {
#
# This function simply initialises the default rootkit
# files and directories.
#
# 55808 Variant A
W55808A_FILES="/tmp/.../r
/tmp/.../a"
W55808A_DIRS=
W55808A_KSYMS=
# Adore Rootkit. OK, nobody calls it that but basically it uses Adore.
# In one commercial AV vendors naming scheme it's called Dextenea.
AKIT_FILES="/usr/secure
/usr/doc/sys/qrt
/usr/doc/sys/run
/usr/doc/sys/crond
/usr/sbin/kfd
/usr/doc/kern/var
/usr/doc/kern/string.o
/usr/doc/kern/ava
/usr/doc/kern/adore.o
/var/log/ssh/old"
AKIT_DIRS="/lib/security/.config/ssh
/usr/doc/kern
/usr/doc/backup
/usr/doc/backup/txt
/lib/backup
/lib/backup/txt
/usr/doc/work
/usr/doc/sys
/var/log/ssh
/usr/doc/.spool
/usr/lib/kterm"
AKIT_KSYMS=
# AjaKit Rootkit
AJAKIT_FILES="/dev/tux/.addr
/dev/tux/.proc
/dev/tux/.file
/lib/.libgh-gh/cleaner
/lib/.libgh-gh/Patch/patch
/lib/.libgh-gh/sb0k"
AJAKIT_DIRS="/dev/tux
/lib/.libgh-gh"
AJAKIT_KSYMS=
# aPa Kit Rootkit
APAKIT_FILES="/usr/share/.aPa"
APAKIT_DIRS=
APAKIT_KSYMS=
# Apache Worm
APACHEWORM_FILES="/bin/.log"
APACHEWORM_DIRS=
APACHEWORM_KSYMS=
# Ambient (ark) Rootkit
ARK_FILES="/usr/lib/.ark?
/dev/ptyxx/.log
/dev/ptyxx/.file
/dev/ptyxx/.proc
/dev/ptyxx/.addr"
ARK_DIRS="/dev/ptyxx"
ARK_KSYMS=
# Balaur Rootkit 2.0 (LRK5 based)
BALAUR_FILES="/usr/lib/liblog.o"
BALAUR_DIRS="/usr/lib/.kinetic
/usr/lib/.egcs
/usr/lib/.wormie"
BALAUR_KSYMS=
# Beastkit Rootkit
BEASTKIT_FILES="/usr/sbin/arobia
/usr/sbin/idrun
/usr/lib/elm/arobia/elm
/usr/lib/elm/arobia/elm/hk
/usr/lib/elm/arobia/elm/hk.pub
/usr/lib/elm/arobia/elm/sc
/usr/lib/elm/arobia/elm/sd.pp
/usr/lib/elm/arobia/elm/sdco
/usr/lib/elm/arobia/elm/srsd"
BEASTKIT_DIRS="/lib/ldd.so/bktools"
BEASTKIT_KSYMS=
# beX2 Rootkit
BEX_FILES="/usr/info/termcap.info-5.gz
/usr/bin/sshd2"
BEX_DIRS="/usr/include/bex"
BEX_KSYMS=
# BOBkit Rootkit
BOBKIT_FILES="/usr/sbin/ntpsx
/usr/sbin/.../bkit-ava
/usr/sbin/.../bkit-d
/usr/sbin/.../bkit-shd
/usr/sbin/.../bkit-f
/usr/include/.../proc.h
/usr/include/.../.bash_history
/usr/include/.../bkit-get
/usr/include/.../bkit-dl
/usr/include/.../bkit-screen
/usr/include/.../bkit-sleep
/usr/lib/.../bkit-adore.o
/usr/lib/.../ls
/usr/lib/.../netstat
/usr/lib/.../lsof
/usr/lib/.../bkit-ssh/bkit-shdcfg
/usr/lib/.../bkit-ssh/bkit-shhk
/usr/lib/.../bkit-ssh/bkit-pw
/usr/lib/.../bkit-ssh/bkit-shrs
/usr/lib/.../bkit-ssh/bkit-mots
/usr/lib/.../uconf.inv
/usr/lib/.../psr
/usr/lib/.../find
/usr/lib/.../pstree
/usr/lib/.../slocate
/usr/lib/.../du
/usr/lib/.../top"
BOBKIT_DIRS="/usr/sbin/...
/usr/include/...
/usr/include/.../.tmp
/usr/lib/...
/usr/lib/.../.ssh
/usr/lib/.../bkit-ssh
/usr/lib/.bkit-
/tmp/.bkp"
BOBKIT_KSYMS=
# OSX Boonana-A Trojan (aka Koobface.A)
BOONANA_FILES="/Library/StartupItems/OSXDriverUpdates/OSXDriverUpdates
/Library/StartupItems/OSXDriverUpdates/StartupParameters.plist"
BOONANA_DIRS="/var/root/.jnana"
BOONANA_KSYMS=
# cb Rootkit (w00tkit by ZeeN)
# The '%' character represents a space.
# xC.o = Adore LKM
CB_FILES="/dev/srd0
/lib/libproc.so.2.0.6
/dev/mounnt
/etc/rc.d/init.d/init
/usr/bin/.zeen/..%/cl
/usr/bin/.zeen/..%/.x.tgz
/usr/bin/.zeen/..%/statdx
/usr/bin/.zeen/..%/wted
/usr/bin/.zeen/..%/write
/usr/bin/.zeen/..%/scan
/usr/bin/.zeen/..%/sc
/usr/bin/.zeen/..%/sl2
/usr/bin/.zeen/..%/wroot
/usr/bin/.zeen/..%/wscan
/usr/bin/.zeen/..%/wu
/usr/bin/.zeen/..%/v
/usr/bin/.zeen/..%/read
/usr/lib/sshrc
/usr/lib/ssh_host_key
/usr/lib/ssh_host_key.pub
/usr/lib/ssh_random_seed
/usr/lib/sshd_config
/usr/lib/shosts.equiv
/usr/lib/ssh_known_hosts
/u/zappa/.ssh/pid
/usr/bin/.system/..%/tcp.log
/usr/bin/.zeen/..%/curatare/attrib
/usr/bin/.zeen/..%/curatare/chattr
/usr/bin/.zeen/..%/curatare/ps
/usr/bin/.zeen/..%/curatare/pstree
/usr/bin/.system/..%/.x/xC.o"
CB_DIRS="/usr/bin/.zeen
/usr/bin/.zeen/..%/curatare
/usr/bin/.zeen/..%/scan
/usr/bin/.system/..%"
CB_KSYMS=
# CiNIK Worm (Slapper.B variant)
CINIK_FILES="/tmp/.cinik"
CINIK_DIRS="/tmp/.font-unix/.cinik"
CINIK_KSYMS=
# CX Rootkit
CXKIT_FILES="/usr/lib/ldlibso
/usr/lib/configlibso
/usr/lib/shklibso
/usr/lib/randomlibso
/usr/lib/ldlibstrings.so
/usr/lib/ldlibdu.so
/usr/lib/ldlibns.so
/usr/include/db"
CXKIT_DIRS="/usr/include/cxk"
CXKIT_KSYMS=
# Danny-Boy's Abuse Kit
DANNYBOYS_FILES="/dev/mdev
/usr/lib/libX.a"
DANNYBOYS_DIRS=
DANNYBOYS_KSYMS=
# Devil Rootkit
DEVIL_FILES="/var/lib/games/.src
/dev/dsx
/dev/caca
/dev/pro
/bin/bye
/bin/homedir
/usr/bin/xfss
/usr/sbin/tzava
/usr/doc/tar/.../.dracusor/stuff/holber
/usr/doc/tar/.../.dracusor/stuff/sense
/usr/doc/tar/.../.dracusor/stuff/clear
/usr/doc/tar/.../.dracusor/stuff/tzava
/usr/doc/tar/.../.dracusor/stuff/citeste
/usr/doc/tar/.../.dracusor/stuff/killrk
/usr/doc/tar/.../.dracusor/stuff/searchlog
/usr/doc/tar/.../.dracusor/stuff/gaoaza
/usr/doc/tar/.../.dracusor/stuff/cleaner
/usr/doc/tar/.../.dracusor/stuff/shk
/usr/doc/tar/.../.dracusor/stuff/srs
/usr/doc/tar/.../.dracusor/utile.tgz
/usr/doc/tar/.../.dracusor/webpage
/usr/doc/tar/.../.dracusor/getpsy
/usr/doc/tar/.../.dracusor/getbnc
/usr/doc/tar/.../.dracusor/getemech
/usr/doc/tar/.../.dracusor/localroot.sh
/usr/doc/tar/.../.dracusor/stuff/old/sense"
DEVIL_DIRS="/usr/doc/tar/.../.dracusor"
DEVIL_KSYMS=
# Dica-Kit (T0rn variant) Rootkit
DICA_FILES="/lib/.sso
/lib/.so
/var/run/...dica/clean
/var/run/...dica/dxr
/var/run/...dica/read
/var/run/...dica/write
/var/run/...dica/lf
/var/run/...dica/xl
/var/run/...dica/xdr
/var/run/...dica/psg
/var/run/...dica/secure
/var/run/...dica/rdx
/var/run/...dica/va
/var/run/...dica/cl.sh
/var/run/...dica/last.log
/usr/bin/.etc
/etc/sshd_config
/etc/ssh_host_key
/etc/ssh_random_seed"
DICA_DIRS="/var/run/...dica
/var/run/...dica/mh
/var/run/...dica/scan"
DICA_KSYMS=
# Dreams Rootkit
DREAMS_FILES="/dev/ttyoa
/dev/ttyof
/dev/ttyop
/usr/bin/sense
/usr/bin/sl2
/usr/bin/logclear
/usr/bin/(swapd)
/usr/bin/initrd
/usr/bin/crontabs
/usr/bin/snfs
/usr/lib/libsss
/usr/lib/libsnf.log
/usr/lib/libshtift/top
/usr/lib/libshtift/ps
/usr/lib/libshtift/netstat
/usr/lib/libshtift/ls
/usr/lib/libshtift/ifconfig
/usr/include/linseed.h
/usr/include/linpid.h
/usr/include/linkey.h
/usr/include/linconf.h
/usr/include/iceseed.h
/usr/include/icepid.h
/usr/include/icekey.h
/usr/include/iceconf.h"
DREAMS_DIRS="/dev/ida/.hpd
/usr/lib/libshtift"
DREAMS_KSYMS=
# Duarawkz Rootkit
DUARAWKZ_FILES="/usr/bin/duarawkz/loginpass"
DUARAWKZ_DIRS="/usr/bin/duarawkz"
DUARAWKZ_KSYMS=
# ENYE LKM v1.1, v1.2
# Installer default.
ENYELKM_FILES="/etc/.enyelkmHIDE^IT.ko
/etc/.enyelkmOCULTAR.ko"
ENYELKM_DIRS=
ENYELKM_KSYMS=
# Flea Linux Rootkit
FLEA_FILES="/etc/ld.so.hash
/lib/security/.config/ssh/sshd_config
/lib/security/.config/ssh/ssh_host_key
/lib/security/.config/ssh/ssh_host_key.pub
/lib/security/.config/ssh/ssh_random_seed
/usr/bin/ssh2d
/usr/lib/ldlibns.so
/usr/lib/ldlibps.so
/usr/lib/ldlibpst.so
/usr/lib/ldlibdu.so
/usr/lib/ldlibct.so"
FLEA_DIRS="/lib/security/.config/ssh
/dev/..0
/dev/..0/backup"
FLEA_KSYMS=
# FreeBSD Rootkit (FBRK) catering to versions and compile-time defaults used by:
# 1.0 (1997, Method), 1.2 (1997, Method), "ImperialS-FBRK 1.0" (2001, Nyo)
FREEBSD_RK_FILES="/dev/ptyp
/dev/ptyq
/dev/ptyr
/dev/ptys
/dev/ptyt
/dev/fd/.88/freshb-bsd
/dev/fd/.88/fresht
/dev/fd/.88/zxsniff
/dev/fd/.88/zxsniff.log
/dev/fd/.99/.ttyf00
/dev/fd/.99/.ttyp00
/dev/fd/.99/.ttyq00
/dev/fd/.99/.ttys00
/dev/fd/.99/.pwsx00
/etc/.acid
/usr/lib/.fx/sched_host.2
/usr/lib/.fx/random_d.2
/usr/lib/.fx/set_pid.2
/usr/lib/.fx/setrgrp.2
/usr/lib/.fx/TOHIDE
/usr/lib/.fx/cons.saver
/usr/lib/.fx/adore/ava/ava
/usr/lib/.fx/adore/adore/adore.ko
/bin/sysback
/usr/local/bin/sysback"
FREEBSD_RK_DIRS="/dev/fd/.88
/dev/fd/.99
/usr/lib/.fx
/usr/lib/.fx/adore"
FREEBSD_RK_KSYMS=
# Fu Rootkit
FU_FILES="/sbin/xc
/usr/include/ivtype.h
/bin/.lib"
FU_DIRS=
FU_KSYMS=
# Fuckit Rootkit
FUCKIT_FILES="/lib/libproc.so.2.0.7
/dev/proc/.bash_profile
/dev/proc/.bashrc
/dev/proc/.cshrc
/dev/proc/fuckit/hax0r
/dev/proc/fuckit/hax0rshell
/dev/proc/fuckit/config/lports
/dev/proc/fuckit/config/rports
/dev/proc/fuckit/config/rkconf
/dev/proc/fuckit/config/password
/dev/proc/fuckit/config/progs
/dev/proc/fuckit/system-bins/init
/usr/lib/libcps.a
/usr/lib/libtty.a"
FUCKIT_DIRS="/dev/proc
/dev/proc/fuckit
/dev/proc/fuckit/system-bins
/dev/proc/toolz"
FUCKIT_KSYMS=
# GasKit Rootkit
GASKIT_FILES="/dev/dev/gaskit/sshd/sshdd"
GASKIT_DIRS="/dev/dev
/dev/dev/gaskit
/dev/dev/gaskit/sshd"
GASKIT_KSYMS=
# Heroin LKM
HEROIN_FILES=
HEROIN_DIRS=
HEROIN_KSYMS="heroin"
# HjC Kit Rootkit
HJCKIT_FILES=
HJCKIT_DIRS="/dev/.hijackerz"
HJCKIT_KSYMS=
# ignoKit Rootkit
IGNOKIT_FILES="/lib/defs/p
/lib/defs/q
/lib/defs/r
/lib/defs/s
/lib/defs/t
/usr/lib/defs/p
/usr/lib/defs/q
/usr/lib/defs/r
/usr/lib/defs/s
/usr/lib/defs/t
/usr/lib/.libigno/pkunsec
/usr/lib/.libigno/.igno/psybnc/psybnc"
IGNOKIT_DIRS="/usr/lib/.libigno
/usr/lib/.libigno/.igno"
IGNOKIT_KSYMS=
# iLLogiC Rootkit (SunOS Rootkit variant)
ILLOGIC_FILES="/dev/kmod
/dev/dos
/usr/lib/crth.o
/usr/lib/crtz.o
/etc/ld.so.hash
/usr/bin/sia
/usr/bin/ssh2d
/lib/security/.config/sn
/lib/security/.config/iver
/lib/security/.config/uconf.inv
/lib/security/.config/ssh/ssh_host_key
/lib/security/.config/ssh/ssh_host_key.pub
/lib/security/.config/ssh/sshport
/lib/security/.config/ssh/ssh_random_seed
/lib/security/.config/ava
/lib/security/.config/cleaner
/lib/security/.config/lpsched
/lib/security/.config/sz
/lib/security/.config/rcp
/lib/security/.config/patcher
/lib/security/.config/pg
/lib/security/.config/crypt
/lib/security/.config/utime
/lib/security/.config/wget
/lib/security/.config/instmod
/lib/security/.config/bin/find
/lib/security/.config/bin/du
/lib/security/.config/bin/ls
/lib/security/.config/bin/psr
/lib/security/.config/bin/netstat
/lib/security/.config/bin/su
/lib/security/.config/bin/ping
/lib/security/.config/bin/passwd"
ILLOGIC_DIRS="/lib/security/.config
/lib/security/.config/ssh
/lib/security/.config/bin
/lib/security/.config/backup
/root/%%%/.dir
/root/%%%/.dir/mass-scan
/root/%%%/.dir/flood"
ILLOGIC_KSYMS=
# OSX Inqtana (Variant A)
INQTANAA_FILES="/Users/w0rm-support.tgz
/Users/InqTest.class
/Users/com.openbundle.plist
/Users/com.pwned.plist
/Users/libavetanaBT.jnilib"
INQTANAA_DIRS="/Users/de
/Users/javax"
INQTANAA_KSYMS=
# OSX Inqtana (Variant B)
INQTANAB_FILES="/Users/w0rms.love.apples.tgz
/Users/InqTest.class
/Users/InqTest.java
/Users/libavetanaBT.jnilib
/Users/InqTanaHandler
/Users/InqTanaHandler.bundle"
INQTANAB_DIRS="/Users/de
/Users/javax"
INQTANAB_KSYMS=
# OSX Inqtana (Variant C)
INQTANAC_FILES="/Users/applec0re.tgz
/Users/InqTest.class
/Users/InqTest.java
/Users/libavetanaBT.jnilib
/Users/environment.plist
/Users/pwned.c
/Users/pwned.dylib"
INQTANAC_DIRS="/Users/de
/Users/javax"
INQTANAC_KSYMS=
# IntoXonia-NG Rootkit
INTOXONIA_FILES=
INTOXONIA_DIRS=
INTOXONIA_KSYMS="funces
ixinit
tricks
kernel_unlink
rootme
hide_module
find_sys_call_tbl"
# Irix Rootkit (for Irix 6.x)
IRIXRK_FILES=
IRIXRK_DIRS="/dev/pts/01
/dev/pts/01/backup
/dev/pts/01/etc
/dev/pts/01/tmp"
IRIXRK_KSYMS=
# Jynx Rootkit
JYNX_FILES="/xochikit/bc
/xochikit/ld_poison.so
/omgxochi/bc
/omgxochi/ld_poison.so
/var/local/^^/bc
/var/local/^^/ld_poison.so"
JYNX_DIRS="/xochikit
/omgxochi
/var/local/^^"
JYNX_KSYMS=
# KBeast (Kernel Beast) Rootkit
KBEAST_FILES="/usr/_h4x_/ipsecs-kbeast-v1.ko
/usr/_h4x_/_h4x_bd
/usr/_h4x_/acctlog"
KBEAST_DIRS="/usr/_h4x_"
KBEAST_KSYMS="h4x_delete_module
h4x_getdents64
h4x_kill
h4x_open
h4x_read
h4x_rename
h4x_rmdir
h4x_tcp4_seq_show
h4x_write"
# Kitko Rootkit
KITKO_FILES=
KITKO_DIRS="/usr/src/redhat/SRPMS/..."
KITKO_KSYMS=
# Knark Rootkit
KNARK_FILES="/proc/knark/pids"
KNARK_DIRS="/proc/knark"
KNARK_KSYMS=
# ld-linuxv.so (LD_PRELOAD shared library rootkit)
LINUXV_FILES="/lib/ld-linuxv.so.1"
LINUXV_DIRS="/var/opt/_so_cache
/var/opt/_so_cache/ld
/var/opt/_so_cache/lc"
LINUXV_KSYMS=
# Lion Worm
LION_FILES="/bin/in.telnetd
/bin/mjy
/usr/man/man1/man1/lib/.lib/mjy
/usr/man/man1/man1/lib/.lib/in.telnetd
/usr/man/man1/man1/lib/.lib/.x
/dev/.lib/lib/scan/1i0n.sh
/dev/.lib/lib/scan/hack.sh
/dev/.lib/lib/scan/bind
/dev/.lib/lib/scan/randb
/dev/.lib/lib/scan/scan.sh
/dev/.lib/lib/scan/pscan
/dev/.lib/lib/scan/star.sh
/dev/.lib/lib/scan/bindx.sh
/dev/.lib/lib/scan/bindname.log
/dev/.lib/lib/1i0n.sh
/dev/.lib/lib/lib/netstat
/dev/.lib/lib/lib/dev/.1addr
/dev/.lib/lib/lib/dev/.1logz
/dev/.lib/lib/lib/dev/.1proc
/dev/.lib/lib/lib/dev/.1file"
LION_DIRS=
LION_KSYMS=
# Lockit Rootkit (aka LJK2)
LOCKIT_FILES="/usr/lib/libmen.oo/.LJK2/ssh_config
/usr/lib/libmen.oo/.LJK2/ssh_host_key
/usr/lib/libmen.oo/.LJK2/ssh_host_key.pub
/usr/lib/libmen.oo/.LJK2/ssh_random_seed*
/usr/lib/libmen.oo/.LJK2/sshd_config
/usr/lib/libmen.oo/.LJK2/backdoor/RK1bd
/usr/lib/libmen.oo/.LJK2/backup/du
/usr/lib/libmen.oo/.LJK2/backup/ifconfig
/usr/lib/libmen.oo/.LJK2/backup/inetd.conf
/usr/lib/libmen.oo/.LJK2/backup/locate
/usr/lib/libmen.oo/.LJK2/backup/login
/usr/lib/libmen.oo/.LJK2/backup/ls
/usr/lib/libmen.oo/.LJK2/backup/netstat
/usr/lib/libmen.oo/.LJK2/backup/ps
/usr/lib/libmen.oo/.LJK2/backup/pstree
/usr/lib/libmen.oo/.LJK2/backup/rc.sysinit
/usr/lib/libmen.oo/.LJK2/backup/syslogd
/usr/lib/libmen.oo/.LJK2/backup/tcpd
/usr/lib/libmen.oo/.LJK2/backup/top
/usr/lib/libmen.oo/.LJK2/clean/RK1sauber
/usr/lib/libmen.oo/.LJK2/clean/RK1wted
/usr/lib/libmen.oo/.LJK2/hack/RK1parse
/usr/lib/libmen.oo/.LJK2/hack/RK1sniff
/usr/lib/libmen.oo/.LJK2/hide/.RK1addr
/usr/lib/libmen.oo/.LJK2/hide/.RK1dir
/usr/lib/libmen.oo/.LJK2/hide/.RK1log
/usr/lib/libmen.oo/.LJK2/hide/.RK1proc
/usr/lib/libmen.oo/.LJK2/hide/RK1phidemod.c
/usr/lib/libmen.oo/.LJK2/modules/README.modules
/usr/lib/libmen.oo/.LJK2/modules/RK1hidem.c
/usr/lib/libmen.oo/.LJK2/modules/RK1phide
/usr/lib/libmen.oo/.LJK2/sshconfig/RK1ssh"
LOCKIT_DIRS="/usr/lib/libmen.oo/.LJK2"
LOCKIT_KSYMS=
# MRK (MiCrobul?) RootKit (based on Devil RootKit, also see Xzibit)
MRK_FILES="/dev/ida/.inet/pid
/dev/ida/.inet/ssh_host_key
/dev/ida/.inet/ssh_random_seed
/dev/ida/.inet/tcp.log"
MRK_DIRS="/dev/ida/.inet
/var/spool/cron/.sh"
MRK_KSYMS=
# Mood-NT Rootkit
# Binary is by default called "mood-nt" but can be anywhere.
# Here we look for collaterals, from include/prefs.h defaults
# until sig-based dirscan() is added.
MOODNT_FILES="/sbin/init__mood-nt-_-_cthulhu
/_cthulhu/mood-nt.init
/_cthulhu/mood-nt.conf
/_cthulhu/mood-nt.sniff"
MOODNT_DIRS="/_cthulhu"
MOODNT_KSYMS=
# Ni0 Rootkit
NIO_FILES="/var/lock/subsys/...datafile.../...net...
/var/lock/subsys/...datafile.../...port...
/var/lock/subsys/...datafile.../...ps...
/var/lock/subsys/...datafile.../...file..."
NIO_DIRS="/tmp/waza
/var/lock/subsys/...datafile...
/usr/sbin/es"
NIO_KSYMS=
# Ohhara Rootkit
OHHARA_FILES="/var/lock/subsys/...datafile.../...datafile.../in.smbd.log"
OHHARA_DIRS="/var/lock/subsys/...datafile...
/var/lock/subsys/...datafile.../...datafile...
/var/lock/subsys/...datafile.../...datafile.../bin
/var/lock/subsys/...datafile.../...datafile.../usr/bin
/var/lock/subsys/...datafile.../...datafile.../usr/sbin
/var/lock/subsys/...datafile.../...datafile.../lib/security"
OHHARA_KSYMS=
# Optic Kit (Tux variant) Rootkit
OPTICKIT_FILES=
OPTICKIT_DIRS="/dev/tux
/usr/bin/xchk
/usr/bin/xsf
/usr/bin/ssh2d"
OPTICKIT_KSYMS=
# OSX Rootkit 0.2.1 (OSXRK)
OSXRK_FILES="/dev/.rk/nc
/dev/.rk/diepu
/dev/.rk/backd
/Library/StartupItems/opener
/Library/StartupItems/opener.sh
/System/Library/StartupItems/opener
/System/Library/StartupItems/opener.sh"
OSXRK_DIRS="/dev/.rk
/Users/LDAP-daemon
/tmp/.work"
OSXRK_KSYMS=
# Oz Rootkit
OZ_FILES="/dev/.oz/.nap/rkit/terror"
OZ_DIRS="/dev/.oz"
OZ_KSYMS=
# Phalanx Rootkit
PHALANX_FILES="/uNFuNF
/etc/host.ph1
/bin/host.ph1
/usr/share/.home.ph1/phalanx
/usr/share/.home.ph1/cb
/usr/share/.home.ph1/kebab"
PHALANX_DIRS="/usr/share/.home.ph1
/usr/share/.home.ph1/tty"
PHALANX_KSYMS=
# Phalanx2 Rootkit
PHALANX2_FILES="/etc/khubd.p2/.p2rc
/etc/khubd.p2/.phalanx2
/etc/khubd.p2/.sniff
/etc/khubd.p2/sshgrab.py
/etc/lolzz.p2/.p2rc
/etc/lolzz.p2/.phalanx2
/etc/lolzz.p2/.sniff
/etc/lolzz.p2/sshgrab.py
/etc/cron.d/zupzzplaceholder
/usr/lib/zupzz.p2/.p-2.3d
/usr/lib/zupzz.p2/.p2rc"
PHALANX2_DIRS="/etc/khubd.p2
/etc/lolzz.p2
/usr/lib/zupzz.p2"
PHALANX2_KSYMS=
# Portacelo Rootkit
PORTACELO_FILES="/var/lib/.../.ak
/var/lib/.../.hk
/var/lib/.../.rs
/var/lib/.../.p
/var/lib/.../getty
/var/lib/.../lkt.o
/var/lib/.../show
/var/lib/.../nlkt.o
/var/lib/.../ssshrc
/var/lib/.../sssh_equiv
/var/lib/.../sssh_known_hosts
/var/lib/.../sssh_pid ~/.sssh/known_hosts"
PORTACELO_DIRS=
PORTACELO_KSYMS=
# R3dstorm Toolkit
REDSTORM_FILES="/var/log/tk02/see_all
/var/log/tk02/.scris
/bin/.../sshd/sbin/sshd1
/bin/.../hate/sk
/bin/.../see_all"
REDSTORM_DIRS="/var/log/tk02
/var/log/tk02/old
/bin/..."
REDSTORM_KSYMS=
# RH-Sharpe's Rootkit
RHSHARPES_FILES="/bin/lps
/usr/bin/lpstree
/usr/bin/ltop
/usr/bin/lkillall
/usr/bin/ldu
/usr/bin/lnetstat
/usr/bin/wp
/usr/bin/shad
/usr/bin/vadim
/usr/bin/slice
/usr/bin/cleaner
/usr/include/rpcsvc/du"
RHSHARPES_DIRS=
RHSHARPES_KSYMS=
# RSHA's Rootkit
RSHA_FILES="/bin/kr4p
/usr/bin/n3tstat
/usr/bin/chsh2
/usr/bin/slice2
/usr/src/linux/arch/alpha/lib/.lib/.1proc
/etc/rc.d/arch/alpha/lib/.lib/.1addr"
RSHA_DIRS="/etc/rc.d/rsha
/etc/rc.d/arch/alpha/lib/.lib"
RSHA_KSYMS=
# Shutdown Rootkit
# The '%' character represents a space.
SHUTDOWN_FILES="/usr/man/man5/..%/.dir/scannah/asus
/usr/man/man5/..%/.dir/see
/usr/man/man5/..%/.dir/nscd
/usr/man/man5/..%/.dir/alpd
/etc/rc.d/rc.local%"
SHUTDOWN_DIRS="/usr/man/man5/..%/.dir
/usr/man/man5/..%/.dir/scannah
/etc/rc.d/rc0.d/..%/.dir"
SHUTDOWN_KSYMS=
# Scalper (FreeBSD.Scalper.Worm) Worm
SCALPER_FILES="/tmp/.a
/tmp/.uua"
SCALPER_DIRS=
SCALPER_KSYMS=
# SHV4 Rootkit
SHV4_FILES="/etc/ld.so.hash
/lib/libext-2.so.7
/lib/lidps1.so
/lib/libproc.a
/lib/libproc.so.2.0.6
/lib/ldd.so/tks
/lib/ldd.so/tkp
/lib/ldd.so/tksb
/lib/security/.config/sshd
/lib/security/.config/ssh/ssh_host_key
/lib/security/.config/ssh/ssh_host_key.pub
/lib/security/.config/ssh/ssh_random_seed
/usr/include/file.h
/usr/include/hosts.h
/usr/include/lidps1.so
/usr/include/log.h
/usr/include/proc.h
/usr/sbin/xntps
/dev/srd0"
SHV4_DIRS="/lib/ldd.so
/lib/security/.config
/lib/security/.config/ssh"
SHV4_KSYMS=
# SHV5 Rootkit
SHV5_FILES="/etc/sh.conf
/lib/libproc.a
/lib/libproc.so.2.0.6
/lib/lidps1.so
/lib/libsh.so/bash
/usr/include/file.h
/usr/include/hosts.h
/usr/include/log.h
/usr/include/proc.h
/lib/libsh.so/shdcf2
/lib/libsh.so/shhk
/lib/libsh.so/shhk.pub
/lib/libsh.so/shrs
/usr/lib/libsh/.bashrc
/usr/lib/libsh/shsb
/usr/lib/libsh/hide
/usr/lib/libsh/.sniff/shsniff
/usr/lib/libsh/.sniff/shp
/dev/srd0"
SHV5_DIRS="/lib/libsh.so
/usr/lib/libsh
/usr/lib/libsh/utilz
/usr/lib/libsh/.backup"
SHV5_KSYMS=
# Sin Rootkit
SINROOTKIT_FILES="/dev/.haos/haos1/.f/Denyed
/dev/ttyoa
/dev/ttyof
/dev/ttyop
/dev/ttyos
/usr/lib/.lib
/usr/lib/sn/.X
/usr/lib/sn/.sys
/usr/lib/ld/.X
/usr/man/man1/...
/usr/man/man1/.../.m
/usr/man/man1/.../.w"
SINROOTKIT_DIRS="/usr/lib/sn
/usr/lib/man1/...
/dev/.haos"
SINROOTKIT_KSYMS=
# Slapper Worm
SLAPPER_FILES="/tmp/.bugtraq
/tmp/.uubugtraq
/tmp/.bugtraq.c
/tmp/httpd
/tmp/.unlock
/tmp/update
/tmp/.cinik
/tmp/.b"
SLAPPER_DIRS=
SLAPPER_KSYMS=
# Sneakin Rootkit
SNEAKIN_FILES=
SNEAKIN_DIRS="/tmp/.X11-unix/.../rk"
SNEAKIN_KSYMS=
# Solaris Wanuk backdoor
WANUKDOOR_FILES="/var/adm/sa/.adm/.lp-door.i86pc
/var/adm/sa/.adm/.lp-door.sun4
/var/spool/lp/admins/.lp-door.i86pc
/var/spool/lp/admins/.lp-door.sun4
/var/spool/lp/admins/lpshut
/var/spool/lp/admins/lpsystem
/var/spool/lp/admins/lpadmin
/var/spool/lp/admins/lpmove
/var/spool/lp/admins/lpusers
/var/spool/lp/admins/lpfilter
/var/spool/lp/admins/lpstat
/var/spool/lp/admins/lpd
/var/spool/lp/admins/lpsched
/var/spool/lp/admins/lpc"
WANUKDOOR_DIRS="/var/adm/sa/.adm"
WANUKDOOR_KSYMS=
# Solaris Wanuk Worm (ELF_WANUK.A)
WANUKWORM_FILES="/var/adm/.adm
/var/adm/.i86pc
/var/adm/.sun4
/var/adm/sa/.adm
/var/adm/sa/.adm/.i86pc
/var/adm/sa/.adm/.sun4
/var/adm/sa/.adm/.crontab
/var/adm/sa/.adm/devfsadmd
/var/adm/sa/.adm/svcadm
/var/adm/sa/.adm/cfgadm
/var/adm/sa/.adm/kadmind
/var/adm/sa/.adm/zoneadmd
/var/adm/sa/.adm/sadm
/var/adm/sa/.adm/sysadm
/var/adm/sa/.adm/dladm
/var/adm/sa/.adm/bootadm
/var/adm/sa/.adm/routeadm
/var/adm/sa/.adm/uadmin
/var/adm/sa/.adm/acctadm
/var/adm/sa/.adm/cryptoadm
/var/adm/sa/.adm/inetadm
/var/adm/sa/.adm/logadm
/var/adm/sa/.adm/nlsadmin
/var/adm/sa/.adm/sacadm
/var/adm/sa/.adm/syseventadmd
/var/adm/sa/.adm/ttyadmd
/var/adm/sa/.adm/consadmd
/var/adm/sa/.adm/metadevadm
/var/adm/sa/.i86pc
/var/adm/sa/.sun4
/var/adm/sa/acctadm
/var/adm/sa/bootadm
/var/adm/sa/cfgadm
/var/adm/sa/consadmd
/var/adm/sa/cryptoadm
/var/adm/sa/devfsadmd
/var/adm/sa/dladm
/var/adm/sa/inetadm
/var/adm/sa/kadmind
/var/adm/sa/logadm
/var/adm/sa/metadevadm
/var/adm/sa/nlsadmin
/var/adm/sa/routeadm
/var/adm/sa/sacadm
/var/adm/sa/sadm
/var/adm/sa/svcadm
/var/adm/sa/sysadm
/var/adm/sa/syseventadmd
/var/adm/sa/ttyadmd
/var/adm/sa/uadmin
/var/adm/sa/zoneadmd
/var/spool/lp/admins/.lp/.crontab
/var/spool/lp/admins/.lp/lpshut
/var/spool/lp/admins/.lp/lpsystem
/var/spool/lp/admins/.lp/lpadmin
/var/spool/lp/admins/.lp/lpmove
/var/spool/lp/admins/.lp/lpusers
/var/spool/lp/admins/.lp/lpfilter
/var/spool/lp/admins/.lp/lpstat
/var/spool/lp/admins/.lp/lpd
/var/spool/lp/admins/.lp/lpsched
/var/spool/lp/admins/.lp/lpc"
WANUKWORM_DIRS="/var/adm/sa/.adm
/var/spool/lp/admins/.lp"
WANUKWORM_KSYMS=
# 'Spanish' Rootkit
SPANISH_FILES="/dev/ptyq
/bin/ad
/bin/ava
/bin/server
/usr/sbin/rescue
/usr/share/.../chrps
/usr/share/.../chrifconfig
/usr/share/.../netstat
/usr/share/.../linsniffer
/usr/share/.../charbd
/usr/share/.../charbd2
/usr/share/.../charbd3
/usr/share/.../charbd4
/usr/man/tmp/update.tgz
/var/lib/rpm/db.rpm
/var/cache/man/.cat
/var/spool/lpd/remote/.lpq"
SPANISH_DIRS="/usr/share/..."
SPANISH_KSYMS=
# Suckit Rootkit
SUCKIT_FILES="/sbin/initsk12
/sbin/initxrk
/usr/bin/null
/usr/share/locale/sk/.sk12/sk
/etc/rc.d/rc0.d/S23kmdac
/etc/rc.d/rc1.d/S23kmdac
/etc/rc.d/rc2.d/S23kmdac
/etc/rc.d/rc3.d/S23kmdac
/etc/rc.d/rc4.d/S23kmdac
/etc/rc.d/rc5.d/S23kmdac
/etc/rc.d/rc6.d/S23kmdac"
SUCKIT_DIRS="/dev/sdhu0/tehdrakg
/etc/.MG
/usr/share/locale/sk/.sk12
/usr/lib/perl5/site_perl/i386-linux/auto/TimeDate/.packlist"
SUCKIT_KSYMS=
# SunOS / NSDAP Rootkit
NSDAP_FILES="/dev/pts/01/55su
/dev/pts/01/55ps
/dev/pts/01/55ping
/dev/pts/01/55login
/dev/pts/01/PATCHER_COMPLETED
/dev/prom/sn.l
/dev/prom/dos
/usr/lib/vold/nsdap/.kit
/usr/lib/vold/nsdap/defines
/usr/lib/vold/nsdap/patcher
/usr/lib/vold/nsdap/pg
/usr/lib/vold/nsdap/cleaner
/usr/lib/vold/nsdap/utime
/usr/lib/vold/nsdap/crypt
/usr/lib/vold/nsdap/findkit
/usr/lib/vold/nsdap/sn2
/usr/lib/vold/nsdap/sniffload
/usr/lib/vold/nsdap/runsniff
/usr/lib/lpset
/usr/lib/lpstart
/usr/bin/mc68000
/usr/bin/mc68010
/usr/bin/mc68020
/usr/ucb/bin/ps
/usr/bin/m68k
/usr/bin/sun2
/usr/bin/mc68030
/usr/bin/mc68040
/usr/bin/sun3
/usr/bin/sun3x
/usr/bin/lso
/usr/bin/u370"
NSDAP_DIRS="/dev/pts/01
/dev/prom
/usr/lib/vold/nsdap
/.pat"
NSDAP_KSYMS=
# SunOS Rootkit
SUNOSROOTKIT_FILES="/etc/ld.so.hash
/lib/libext-2.so.7
/usr/bin/ssh2d
/bin/xlogin
/usr/lib/crth.o
/usr/lib/crtz.o
/sbin/login
/lib/security/.config/sn
/lib/security/.config/lpsched
/dev/kmod
/dev/dos"
SUNOSROOTKIT_DIRS=
SUNOSROOTKIT_KSYMS=
# Superkit Rootkit (Suckit 1.3b-based)
SUPERKIT_FILES="/usr/man/.sman/sk/backsh
/usr/man/.sman/sk/izbtrag
/usr/man/.sman/sk/sksniff
/var/www/cgi-bin/cgiback.cgi"
SUPERKIT_DIRS="/usr/man/.sman/sk"
SUPERKIT_KSYMS=
# Telnet Backdoor
TBD_FILES="/usr/lib/.tbd"
TBD_DIRS=
TBD_KSYMS=
# TeLeKiT Rootkit
TELEKIT_FILES="/usr/man/man3/.../TeLeKiT/bin/sniff
/usr/man/man3/.../TeLeKiT/bin/telnetd
/usr/man/man3/.../TeLeKiT/bin/teleulo
/usr/man/man3/.../cl
/dev/ptyr
/dev/ptyp
/dev/ptyq
/dev/hda06
/usr/info/libc1.so"
TELEKIT_DIRS="/usr/man/man3/...
/usr/man/man3/.../lsniff
/usr/man/man3/.../TeLeKiT"
TELEKIT_KSYMS=
# OSX Togroot Rootkit
TOGROOT_FILES="/System/Library/Extensions/Togroot.kext/Contents/Info.plist
/System/Library/Extensions/Togroot.kext/Contents/pbdevelopment.plist
/System/Library/Extensions/Togroot.kext/Contents/MacOS/togrootkext"
TOGROOT_DIRS="/System/Library/Extensions/Togroot.kext
/System/Library/Extensions/Togroot.kext/Contents
/System/Library/Extensions/Togroot.kext/Contents/MacOS"
TOGROOT_KSYMS=
# T0rn (and misc) Rootkit
TORN_FILES="/dev/.lib/lib/lib/t0rns
/dev/.lib/lib/lib/du
/dev/.lib/lib/lib/ls
/dev/.lib/lib/lib/t0rnsb
/dev/.lib/lib/lib/ps
/dev/.lib/lib/lib/t0rnp
/dev/.lib/lib/lib/find
/dev/.lib/lib/lib/ifconfig
/dev/.lib/lib/lib/pg
/dev/.lib/lib/lib/ssh.tgz
/dev/.lib/lib/lib/top
/dev/.lib/lib/lib/sz
/dev/.lib/lib/lib/login
/dev/.lib/lib/lib/in.fingerd
/dev/.lib/lib/lib/1i0n.sh
/dev/.lib/lib/lib/pstree
/dev/.lib/lib/lib/in.telnetd
/dev/.lib/lib/lib/mjy
/dev/.lib/lib/lib/sush
/dev/.lib/lib/lib/tfn
/dev/.lib/lib/lib/name
/dev/.lib/lib/lib/getip.sh
/usr/info/.torn/sh*
/usr/src/.puta/.1addr
/usr/src/.puta/.1file
/usr/src/.puta/.1proc
/usr/src/.puta/.1logz
/usr/info/.t0rn"
TORN_DIRS="/dev/.lib
/dev/.lib/lib
/dev/.lib/lib/lib
/dev/.lib/lib/lib/dev
/dev/.lib/lib/scan
/usr/src/.puta
/usr/man/man1/man1
/usr/man/man1/man1/lib
/usr/man/man1/man1/lib/.lib
/usr/man/man1/man1/lib/.lib/.backup"
TORN_KSYMS=
# trNkit Rootkit
TRNKIT_FILES="/usr/lib/libbins.la
/usr/lib/libtcs.so
/dev/.ttpy/ulogin.sh
/dev/.ttpy/tcpshell.sh
/dev/.ttpy/bupdu
/dev/.ttpy/buloc
/dev/.ttpy/buloc1
/dev/.ttpy/buloc2
/dev/.ttpy/stat
/dev/.ttpy/backps
/dev/.ttpy/tree
/dev/.ttpy/topk
/dev/.ttpy/wold
/dev/.ttpy/whoold
/dev/.ttpy/backdoors"
TRNKIT_DIRS=
TRNKIT_KSYMS=
# Trojanit Kit Rootkit
TROJANIT_FILES="/bin/.ls
/bin/.ps
/bin/.netstat
/usr/bin/.nop
/usr/bin/.who"
TROJANIT_DIRS=
TROJANIT_KSYMS=
# Turtle / Turtle2 Rootkit
TURTLE_FILES="/dev/turtle2dev"
TURTLE_DIRS=
TURTLE_KSYMS=
# Tuxtendo (Tuxkit) Rootkit
TUXTENDO_FILES="/lib/libproc.so.2.0.7
/usr/bin/xchk
/usr/bin/xsf
/dev/tux/suidsh
/dev/tux/.addr
/dev/tux/.cron
/dev/tux/.file
/dev/tux/.log
/dev/tux/.proc
/dev/tux/.iface
/dev/tux/.pw
/dev/tux/.df
/dev/tux/.ssh
/dev/tux/.tux
/dev/tux/ssh2/sshd2_config
/dev/tux/ssh2/hostkey
/dev/tux/ssh2/hostkey.pub
/dev/tux/ssh2/logo
/dev/tux/ssh2/random_seed
/dev/tux/backup/crontab
/dev/tux/backup/df
/dev/tux/backup/dir
/dev/tux/backup/find
/dev/tux/backup/ifconfig
/dev/tux/backup/locate
/dev/tux/backup/netstat
/dev/tux/backup/ps
/dev/tux/backup/pstree
/dev/tux/backup/syslogd
/dev/tux/backup/tcpd
/dev/tux/backup/top
/dev/tux/backup/updatedb
/dev/tux/backup/vdir"
TUXTENDO_DIRS="/dev/tux
/dev/tux/ssh2
/dev/tux/backup"
TUXTENDO_KSYMS=
# Universal Rootkit by K2 (URK) Release 0.9.8
URK_FILES="/dev/prom/sn.l
/usr/lib/ldlibps.so
/usr/lib/ldlibnet.so
/dev/pts/01/uconf.inv
/dev/pts/01/cleaner
/dev/pts/01/bin/psniff
/dev/pts/01/bin/du
/dev/pts/01/bin/ls
/dev/pts/01/bin/passwd
/dev/pts/01/bin/ps
/dev/pts/01/bin/psr
/dev/pts/01/bin/su
/dev/pts/01/bin/find
/dev/pts/01/bin/netstat
/dev/pts/01/bin/ping
/dev/pts/01/bin/strings
/dev/pts/01/bin/bash
/usr/man/man1/xxxxxxbin/du
/usr/man/man1/xxxxxxbin/ls
/usr/man/man1/xxxxxxbin/passwd
/usr/man/man1/xxxxxxbin/ps
/usr/man/man1/xxxxxxbin/psr
/usr/man/man1/xxxxxxbin/su
/usr/man/man1/xxxxxxbin/find
/usr/man/man1/xxxxxxbin/netstat
/usr/man/man1/xxxxxxbin/ping
/usr/man/man1/xxxxxxbin/strings
/usr/man/man1/xxxxxxbin/bash
/tmp/conf.inv"
URK_DIRS="/dev/prom
/dev/pts/01
/dev/pts/01/bin
/usr/man/man1/xxxxxxbin"
URK_KSYMS=
# Also-see: /usr/lib/lpset (esniff), /var/lp/lpacct/ (files), /usr/lib/bnclp, /usr/lib/lpsys (identd),
# Also-see: /usr/lib/lptd (backdoor?), /sbin/rc2 and /sbin/rc3 containing string "/usr/lib/lpstart",
# Also-see: dos, psbnc, lpacct, USER, lp,
# Also see: /etc/lpconfig vs /etc/ttyhash, uconv.inv vs urk.conf.
# VcKit Rootkit
VCKIT_FILES=
VCKIT_DIRS="/usr/include/linux/modules/lib.so
/usr/include/linux/modules/lib.so/bin"
VCKIT_KSYMS=
# Vampire Rootkit
VAMPIRE_FILES=
VAMPIRE_DIRS=
VAMPIRE_KSYMS="new_getdents
old_getdents
should_hide_file_name
should_hide_task_name"
# Volc Rootkit
# Omit listing system binaries that should be picked up by changed hashes.
VOLC_FILES="/usr/bin/volc
/usr/lib/volc/backdoor/divine
/usr/lib/volc/linsniff
/etc/rc.d/rc1.d/S25sysconf
/etc/rc.d/rc2.d/S25sysconf
/etc/rc.d/rc3.d/S25sysconf
/etc/rc.d/rc4.d/S25sysconf
/etc/rc.d/rc5.d/S25sysconf"
VOLC_DIRS="/var/spool/.recent
/var/spool/.recent/.files
/usr/lib/volc
/usr/lib/volc/backup"
VOLC_KSYMS=
# weaponX 0.1
WEAPONX_FILES="/System/Library/Extensions/WeaponX.kext"
WEAPONX_DIRS="/tmp/..."
WEAPONX_KSYMS=
# WMKR26 2.0, WindEX, XND Crew, LKM for kernel 2.6
# (2.6.12 - 2.6.19.2, i[456]86 and x86_64)
# These files don't exist and can't be seen:
# /proc/qwerty
# /proc/givemeroot
# /proc/hide+[PID]
# /proc/hide-[PID]
# /proc/active-
# /proc/module_hide+
# /proc/module_hide-
# /proc/givemeinfo
# Xzibit Rootkit (also see MRK (MiCrobul?) RootKit)
XZIBIT_FILES="/dev/dsx
/dev/caca
/dev/ida/.inet/linsniffer
/dev/ida/.inet/logclear
/dev/ida/.inet/sense
/dev/ida/.inet/sl2
/dev/ida/.inet/sshdu
/dev/ida/.inet/s
/dev/ida/.inet/ssh_host_key
/dev/ida/.inet/ssh_random_seed
/dev/ida/.inet/sl2new.c
/dev/ida/.inet/tcp.log
/home/httpd/cgi-bin/becys.cgi
/usr/local/httpd/cgi-bin/becys.cgi
/usr/local/apache/cgi-bin/becys.cgi
/www/httpd/cgi-bin/becys.cgi
/www/cgi-bin/becys.cgi"
XZIBIT_DIRS="/dev/ida/.inet"
XZIBIT_KSYMS=
# X-Org SunOS Rootkit
XORGSUNOS_FILES="/usr/lib/libX.a/bin/tmpfl
/usr/lib/libX.a/bin/rps
/usr/bin/srload
/usr/lib/libX.a/bin/sparcv7/rps
/usr/sbin/modcheck"
XORGSUNOS_DIRS="/usr/lib/libX.a
/usr/lib/libX.a/bin
/usr/lib/libX.a/bin/sparcv7
/usr/share/man..."
XORGSUNOS_KSYMS=
# zaRwT.KiT Rootkit
ZARWT_FILES="/dev/rd/s/sendmeil
/dev/ttyf
/dev/ttyp
/dev/ttyn
/rk/tulz"
ZARWT_DIRS="/rk
/dev/rd/s"
ZARWT_KSYMS=
# ZK Rootkit
ZK_FILES="/usr/share/.zk/zk
/usr/X11R6/.zk/xfs
/usr/X11R6/.zk/echo
/etc/1ssue.net
/etc/sysconfig/console/load.zk"
ZK_DIRS="/usr/share/.zk
/usr/X11R6/.zk"
ZK_KSYMS=
# Miscellaneous login backdoors
LOGIN_BACKDOOR_FILES="/bin/.login
/sbin/.login"
# Suspicious directories
SUSPICIOUS_DIRS="/usr/X11R6/bin/.,/copy
/dev/rd/cdb"
# Evil strings
STRINGSCAN="crond:LOGNAME=root:Illogic Rootkit
hostname:phalanx:Phalanx Rootkit
init:/dev/proc/fuckit:Fuckit Rootkit
init:FUCK:Suckit Rootkit
init:backdoor:Suckit Rootkit (backdoored init file)
init:/usr/bin/rcpc:Portacelo Rootkit
init:/usr/sbin/login:trNkit Rootkit ulogin
killall:/dev/ptyxx/.proc:Ambient (ark) Rootkit
login:vt200:Linux Rootkit (LRK4)
login:/usr/bin/xstat:Linux Rootkit (LRK4)
login:/bin/envpc:Linux Rootkit (LRK4)
login:L4m3r0x:Linux Rootkit (LRK4)
login:/lib/libext:SHV4 Rootkit
login:/usr/sbin/login:Flea Linux Rootkit
login:/usr/lib/.tbd:TBD Rootkit
login:sendmail:Ambient (ark) Rootkit
login:cocacola:cb Rootkit
login:joao:Spanish Rootkit
ls:/dev/ptyxx/.file:Dica-Kit Rootkit
ls:/dev/ptyxx/.file:Ambient (ark) Rootkit
ls:/dev/sgk:Linux Rootkit (LRK4)
ls:/var/lock/subsys/...datafile...:Ohhara Rootkit
ls:/usr/lib/.tbd:TBD Rootkit
netstat:/dev/proc/fuckit:Fuckit Rootkit
netstat:/lib/.sso:Dica-Kit Rootkit
netstat:/var/lock/subsys/...datafile...:Ohhara Rootkit
netstat:/dev/caca:MRK Rootkit
netstat:/dev/ttyoa:Sin Rootkit
netstat:/usr/lib/ldlibns.so:Flea Linux Rootkit
netstat:/dev/ptyxx/.addr:Ambient (ark) Rootkit
netstat:syg:Trojaned netstat
nscd:sshd_config:Backdoor shell installed (SSH)
ps:/var/lock/subsys/...datafile...:Ohhara Rootkit or Ni0 Rootkit
ps:/dev/pts/01:Universal Rootkit (URK)
ps:tw33dl3:SunOS Rootkit
ps:psniff:SunOS Rootkit
ps:uconf.inv:Universal Rootkit (URK)
ps:lib/ldlibps.so:Flea Linux Rootkit or Universal Rootkit (URK)
pstree:/usr/lib/ldlibpst.so:Flea Linux Rootkit
ps:libproc.so.2.0.7:Fuckit Rootkit
ps:/dev/ptyxx/.proc:Ambient (ark) Rootkit
pstree:/dev/ptyxx/.proc:Ambient (ark) Rootkit
pgrep:libproc.so.2.0.7:Fuckit Rootkit
pkill:libproc.so.2.0.7:Fuckit Rootkit
ping:/bin/bash:Ping Rootkit or other backdoor
rpc.nfsd:cant open log:Sniffer installed
rpc.nfsd:sniff.pid:Sniffer installed
rpc.nfsd:tcp.log:Sniffer installed
sshd:/dev/ptyxx:OpenBSD Rootkit
sshd:/.config:SHV4 Rootkit
sshd:+\\$.*\\$\!.*\!\!\\$:Backdoored SSH daemon installed
sshd:backdoor.h:Trojaned SSH daemon
sshd:backdoor_active:Trojaned SSH daemon
sshd:magic_pass_active:Trojaned SSH daemon
sshd:/usr/include/gpm2.h:Trojaned SSH daemon
sshd:/usr/include/openssl:Trojaned SSH daemon
sshd:aion:Trojaned SSH daemon
sshd:pcszPass:Trojaned SSH daemon
sshd:LogPass:Trojaned SSH daemon
sshd:Login_Check:Trojaned SSH daemon
sshd:includes.h:Trojaned SSH daemon
sshd:DecodeString:Trojaned SSH daemon
sshd:EncodeString:Trojaned SSH daemon
xntps:/.config:SHV4 Rootkit
syslogd:promiscuous:Sniffer installed
syslogd:/usr/lib/.tbd:TBD Rootkit
syslogd:/dev/ptyxx/.log:Ambient (ark) Rootkit
syslogd:/usr/share/pci.r:Trojaned Syslog daemon
tcpd:/dev/xdta:Dica-Kit Rootkit
top:/usr/lib/.tbd:TBD Rootkit
top:/dev/ptyxx/.proc:Ambient (ark) Rootkit
xtty:/bin/sh:Backdoor shell
ttymon:fucknut:SHV5 Rootkit
ttymon:lamersucks:SHV5 Rootkit
ttymon:skillz:SHV5 Rootkit
ttyload:/sbin/ttyload:SHV5 Rootkit
ttyload:/sbin/ttymon:SHV5 Rootkit
ttyload:propert of SH:SHV5 Rootkit
rcfile:in.inetd:SHV4 Rootkit
rcfile:+#<HIDE_.*>:Enye LKM
rcfile:bin/xchk:Optic Kit (Tux) Worm
rcfile:bin/xsf:Optic Kit (Tux) Worm
rcfile:/usr/bin/ssh2d:Flea Linux Rootkit or Optic Kit (Tux variant) Rootkit or SunOS Rootkit
rcfile:/usr/sbin/xntps:SHV4 Rootkit
rcfile:ttyload:SHV5 Rootkit
rcfile:/etc/rc.d/init.d/init:cb Rootkit or w00tkit Rootkit
rcfile:usr/bin/xfss:Devil Rootkit
rcfile:/usr/sbin/rpc.netinet:FreeBSD (FBRK) Rootkit
rcfile:/usr/lib/.fx/cons.saver:FreeBSD (FBRK) Rootkit
rcfile:/usr/lib/.fx/xs:FreeBSD (FBRK) Rootkit
rcfile:/ssh2d:Illogic Rootkit or SunOS Rootkit
rcfile:/dev/kmod:Illogic Rootkit or SunOS Rootkit
rcfile:/crth.o:Illogic Rootkit or SunOS Rootkit
rcfile:/crtz.o:Illogic Rootkit or SunOS Rootkit
rcfile:/dev/dos:Illogic Rootkit or SunOS Rootkit
rcfile:/lpq:Illogic Rootkit or SunOS Rootkit
rcfile:/usr/sbin/rescue:Spanish Rootkit
rcfile:/usr/lib/lpstart:SunOS NSDAP Rootkit or Universal Rootkit (URK)
rcfile:/volc:Volc Rootkit
rcfile:sourcemask:Rootkit component
rcfile:/bin/vobiscum:Rootkit component
rcfile:/usr/sbin/in.telnet:Rootkit component
rcfile:/usr/bin/hdparm?-t1?-X53?-p:Xzibit Rootkit
rcfile:/lib/.xsyslog:Flooder (Linux/Bckdr-RKC) component
rcfile:/etc/.xsyslog:Flooder (Linux/Bckdr-RKC) component
rcfile:/lib/.ssyslog:Flooder (Linux/Bckdr-RKC) component
rcfile:/tmp/.sendmail:Flooder (Linux/Bckdr-RKC) component
ssh:/lib/ldd.so/tkps:SHV4 Rootkit
ssh1:/lib/ldd.so/tkps:SHV4 Rootkit
ssh:t0rnkit:T0rn Rootkit
ssh:/dev/proc/fuckit:Fuckit Rootkit
ssh:backdoor.h:Trojaned SSH daemon
ssh:backdoor_active:Trojaned SSH daemon
ssh:magic_pass_active:Trojaned SSH daemon
ssh:/usr/include/gpm2.h:Trojaned SSH daemon
skill:libproc.so.2.0.7:Fuckit Rootkit
snice:libproc.so.2.0.7:Fuckit Rootkit
top:libproc.so.2.0.7:Fuckit Rootkit
slocate:/usr/lib/ldlibct.so:Flea Linux Rootkit
locate:/usr/lib/ldlibct.so:Flea Linux Rootkit
du:/usr/lib/ldlibdu.so:Flea Linux Rootkit
du:/dev/ptyxx/.file:Ambient (ark) Rootkit
w:libproc.so.2.0.7:Fuckit Rootkit
xlogin:/lib/libext:SHV4 Rootkit
hdparm:/dev/ida/.inet:Xzibit Rootkit
pgrep:/usr/include/mysql/mysql.hh1:Rootkit component
pkill:/usr/include/mysql/mysql.hh1:Rootkit component
pmap:/usr/include/mysql/mysql.hh1:Rootkit component
ps:/usr/include/mysql/mysql.hh1:Rootkit component
w:/usr/include/mysql/mysql.hh1:Rootkit component
top:/usr/include/mysql/mysql.hh1:Rootkit component
bc:backconnect:Jynx Rootkit
bc:magic?packet?received:Jynx Rootkit"
# Possible rootkit files and directories
# The '%' character represents a space.
FILESCAN="file:/dev/sdr0:T0rn Rootkit MD5 hash database
file:/dev/pisu:Rootkit component
file:/dev/xdta:Dica-Kit Rootkit
file:/dev/saux:Trojaned SSH daemon sniffer log
file:/dev/hdx:Linux.RST.B infection
file:/dev/hdx1:Linux.RST.B infection
file:/dev/hdx2:Linux.RST.B infection
file:/dev/ptyy:Rootkit component
file:/dev/ptyu:Rootkit component
file:/dev/ptyv:Rootkit component
file:/dev/hdbb:Rootkit component
file:/tmp/.syshackfile:Trojaned syslog daemon
file:/tmp/.bash_history:Lite5-r Rootkit
file:/usr/info/.clib:Backdoor component
file:/usr/sbin/tcp.log:Sniffer log
file:/usr/bin/take/pid:Trojaned SSH daemon
file:/sbin/create:MzOzD Local backdoor
file:/dev/ttypz:spwn login backdoor
file:/var/log/tcp.log:beX2 Rootkit
file:/usr/include/audit.h:beX2 Rootkit
file:/usr/bin/sourcemask:Rootkit component
file:/usr/bin/ras2xm:Rootkit component
file:/dev/xmx:Dica-Kit Rootkit
file:/usr/sbin/gpm.root:Rootkit component
file:/bin/vobiscum:Rootkit component
file:/bin/psr:Rootkit component
file:/dev/kdx:Rootkit component
file:/dev/dkx:Rootkit component
file:/usr/sbin/sshd3:Rootkit component
file:/usr/sbin/jcd:Rootkit component
file:/etc/rc.d/init.d/jcd:Rootkit component
file:/usr/sbin/atd2:Rootkit component
file:/home/httpd/cgi-bin/linux.cgi:Dica-Kit Rootkit
file:/home/httpd/cgi-bin/psid:Dica-Kit Rootkit
file:/home/httpd/cgi-bin/void.cgi:Dica-Kit Rootkit
file:/etc/rc.d/init.d/system:Rootkit component
file:/etc/rc.d/rc3.d/S93users:Rootkit component
file:/tmp/.ush:Dica-Kit Rootkit
file:/usr/lib/libhidefile.so:HIDEFILE envvar file-hiding library
file:/etc/cron.d/kmod:Illogic Rootkit
file:/usr/lib/dmis/dmisd:Trojaned SSH daemon
file:/lib/secure/libhij.so:Solaris Trojaned SSH daemon
file:/usr/sbin/sshd3:Rootkit component
file:/etc/rc.d/init.d/crontab:Rootkit component
file:/etc/rc.d/init.d/jcd:Rootkit component
file:/usr/sbin/atd2:Rootkit component
file:/etc/rc.d/rc5.d/S93users:Rootkit component
file:/usr/include/mysql/mysql.hh1:Rootkit component
file:/etc/init.d/xfs3:Rootkit component
file:/usr/sbin/t.txt:Opyum kit component
file:/usr/sbin/change:Opyum kit component
file:/usr/sbin/s:Opyum kit component
file:/bin/f:Opyum kit component
file:/bin/i:Opyum kit component
file:/lib/libncom.so.4.0.1:ncom rootkit library
file:/sbin/zinit:Rootkit component
file:/tmp/pass_ssh.log:Trojaned SSH daemon
file:/usr/include/gpm2.h:Trojaned SSH daemon
file:/etc/ssh/.sshd_auth:Trojaned SSH daemon (logins)
file:/usr/lib/.sshd.h:Trojaned SSH daemon (logins)
file:/var/run/.defunct:Trojaned SSH daemon
file:/etc/httpd/run/.defunct:Trojaned SSH daemon
file:/usr/share/pci.r:Trojaned Syslog daemon
file:/etc/cron.daily/dnsquery:Sniffer
file:/usr/lib/libutil1.2.1.2.so:Trojaned SSH daemon component (hwclock binary)
file:/bin/ceva:Trojaned SSH daemon (client binary)
file:/sbin/syslogd%:Trojaned SSH daemon (sebd)
file:/usr/include/shup.h:Trojaned SSH daemon (client binary)
file:/etc/rpm/sshdOLD:Trojaned SSH daemon (original sshd binary)
file:/etc/rpm/sshOLD:Trojaned SSH daemon (original ssh binary)
file:/usr/share/passwd.h:Trojaned SSH daemon (default configuration)
file:/lib/.xsyslog:Flooder (Linux/Bckdr-RKC) component
file:/etc/.xsyslog:Flooder (Linux/Bckdr-RKC) component
file:/lib/.ssyslog:Flooder (Linux/Bckdr-RKC) component
file:/tmp/.sendmail:Flooder (Linux/Bckdr-RKC) component
file:/usr/share/sshd.sync:Trojaned SSH daemon
file:/bin/zcut:Trojaned SSH daemon
file:/usr/bin/zmuie:Trojaned SSH daemon
file:/lib/libkeyutils.so.1.9:Sniffer component
file:/lib64/libkeyutils.so.1.9:Sniffer component
file:/usr/lib/libkeyutils.so.1.9:Spam tool component
file:/usr/lib64/libkeyutils.so.1.9:Spam tool component
dir:/dev/ptyas:Langsuir installation directory
dir:/usr/bin/take:Trojaned SSH daemon
dir:/usr/src/.lib:Rootkit component
dir:/usr/share/man/man1/.1c:Eggdrop (IRC bot)
dir:/lib/lblip.tk:T0rn Rootkit directory with backdoored SSH-configuration
dir:/usr/sbin/...:Rootkit component
dir:/usr/share/.gun:Rootkit component
dir:/unde/vrei/tu/sa/te/ascunzi/in/server:Unknown rootkit
dir:/usr/man/man1/..%%/.dir:Unknown rootkit
dir:/usr/X11R6/include/X11/...:Unknown rootkit
dir:/usr/X11R6/lib/X11/.fonts/misc/...:Unknown rootkit
dir:/tmp/.sys:Rootkit component
dir:/tmp/':Rootkit component
dir:/tmp/.,:Rootkit component
dir:/tmp/,.,:Rootkit component
dir:/dev/shm/emilien:Rootkit component
dir:/var/tmp/.log:Rootkit component
dir:/tmp/zmeu/...%:Rootkit component
dir:/var/log/ssh:Rootkit component
dir:/dev/ida:Rootkit component
dir:/var/lib/games/.src/ssk/shit:Rootkit component
dir:/usr/lib/libshtift:Rootkit component
dir:/usr/src/.poop:Ramen worm
dir:/dev/wd4:IRC bot
dir:/var/run/.tmp:Rootkit component
dir:/usr/man/man1/lib/.lib:Rootkit component
dir:/dev/portd:Rootkit component
dir:/dev/...:Rootkit component
dir:/usr/share/man/mansps:Rootkit component
dir:/lib/.so:Rootkit component
dir:/lib/.sso:Rootkit component
dir:/usr/include/sslv3:Rootkit component
dir:/dev/shm/sshd:Trojaned SSH daemon
dir:/usr/share/locale/mk/.dev/sk:Sniffer
dir:/usr/share/locale/mk/.dev:Sniffer
dir:/usr/include/netda.h:Trojaned SSH daemon
dir:/usr/include/.ssh:Trojaned SSH daemon
dir:/usr/share/locale/jp/.%:IRC bot
dir:/usr/share/.sqe:IRC bot"
# Evil strings for FreeBSD KLD (Dynamic Kernel Linker modules)
KLDSTATKEYWORDS="backd00r backdoor darkside nekit rpldev rpldev_mod spapem_core spapem_genr00t hide_process turtle"
# Suspicious startup file strings
RCLOCAL_STRINGS="/usr/bin/rpc.wall:Linux Rootkit (LRK4)
sshdd:GasKit Rootkit
hidef:Knark Rootkit
/usr/bin/.etc:Dica-Kit Rootkit"
# Suspicious open files
SUSP_FILES_INFO="backdoor:Generic backdoor
adore.o:Adore kernel module
mod_rootme.so:Apache mod_rootme backdoor
phide_mod.o:Process hiding kernel module
lbk.ko:LBK FreeBSD kernel module
vlogger.o:THC-Vlogger kernel module
cleaner.o:Adore kernel module
cleaner:Adore Rootkit
ava:Adore Rootkit
tzava:Adore Rootkit
mod_klgr.o:klgr, keyboard logger (kernel module)
hydra:THC-Hydra (password capture)
hydra.restore:THC-Hydra (password capture)
ras2xm:Unknown rootkit
vobiscum:Unknown rootkit
sshd3:Unknown rootkit
system:Unknown rootkit
t0rnsb:T0rn Rootkit
t0rns:T0rn Rootkit
t0rnp:T0rn Rootkit
rx4u:Unknown rootkit
rx2me:Unknown rootkit
sshdu:Unknown rootkit
glotzer:Unknown rootkit
holber:Devil Rootkit
xhide:Process hiding software
xh:Process hiding software (alternative of XHide)
emech:IRC bot
psybnc:IRC bot
mech:IRC bot
httpd.bin:IRC bot
mh:Dica-Kit Rootkit IRC bot
xl:Dica-Kit Rootkit
write:Dica-Kit Rootkit
Phantasmagoria.o:Process hiding Linux kernel module
lkt.o:Portacelo Rootkit
nlkt.o:Portacelo Rootkit
ld_poison.so:Jynx Rootkit
.xsyslog:Flooder (Linux/Bckdr-RKC) component
.ssyslog:Flooder (Linux/Bckdr-RKC) component
pscan2:Port scanner
scanssh:Port scanner
sshf:Possible port scanner
ssh-scan:Port scanner
atac:Port scanner component
\[pdflush\]:IRC bot
libkeyutils.so.1.9:Spam tool component"
# System startup file pathnames
RCLOCATIONS="/etc/rc.d
/etc/rc.local
/usr/local/etc/rc.d
/usr/local/etc/rc.local
/etc/conf.d/local.start
/etc/init.d
/etc/inittab"
# Integrity tests
STRINGS_INTEGRITY="${BOBKIT_FILES} ${BOBKIT_DIRS} ${CINIK_FILES}
${CINIK_DIRS} ${DICA_FILES} ${FREEBSD_RK_FILES}
${TBD_FILES} ${TORN_FILES} ${TORN_DIRS}"
SNIFFER_FILES="/usr/lib/libice.log
/dev/prom/sn.l
/dev/fd/.88/zxsniff.log"
# Known bad Linux kernel modules
LKM_BADNAMES="adore.o
bkit-adore.o
cleaner.o
flkm.o
knark.o
modhide.o
mod_klgr.o
phide_mod.o
vlogger.o
p2.ko
rpldev.o
xC.o
strings.o
wkmr26.ko"
return
}
strings_check() {
#
# This function carries out the 'strings' command check.
# It passes specific strings through the strings command to
# see if they are missing. If so, then it can indicate that
# the command has been modified to hide information.
#
if `check_test strings`; then
display --to LOG --type INFO --screen-nl --nl STARTING_TEST strings
display --to SCREEN+LOG --type PLAIN --screen-indent 2 STRINGS_CHECK_START
else
display --to LOG --type INFO --nl USER_DISABLED_TEST strings
return
fi
#
# First check to see if we have a 'strings' command.
#
if [ -z "${STRINGS_CMD}" ]; then
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --screen-indent 4 STRINGS_CHECK
display --to LOG --type INFO NOT_FOUND_CMD 'strings'
return
fi
STRINGSFAILED=0
for STRING in ${STRINGS_INTEGRITY}; do
STRINGNAME=`echo "${STRING}" | sed -e 's/\./\\\./g'`
STRING_SEEN=`echo "${STRING}" | ${STRINGS_CMD} -a | grep "${STRINGNAME}" | tr -d ' '`
if [ -z "${STRING_SEEN}" ]; then
STRINGSFAILED=1
display --to LOG --type WARNING --result WARNING --log-indent 2 STRINGS_SCANNING_BAD "${STRING}"
elif [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result OK --log-indent 2 STRINGS_SCANNING_OK "${STRING}"
fi
done
if [ $STRINGSFAILED -eq 0 ]; then
RKHTMPVAR="SCREEN"
test $VERBOSE_LOGGING -eq 0 && RKHTMPVAR="SCREEN+LOG"
display --to "${RKHTMPVAR}" --type PLAIN --result OK --color GREEN --screen-indent 4 STRINGS_CHECK
else
display --to SCREEN --type PLAIN --result WARNING --color RED --screen-indent 4 STRINGS_CHECK
fi
return
}
shared_libs_check() {
#
# This function checks shared library loading problems.
# It is part of do_system_commands_checks and should precede or run
# just after strings_check if enabled.
#
#
# Remarks:
# Oracle-10.1.0.3 on RHEL3 needs /etc/libcwait.so,
# F-PROT Antivirus for GNU/Linux needs f-prot.so,
# AVAYA Labs "stack overflow protection" uses libsafe.
#
if `check_test shared_libs`; then
display --to LOG --type INFO --screen-nl --nl STARTING_TEST shared_libs
display --to SCREEN+LOG --type PLAIN --screen-indent 2 SHARED_LIBS_START
else
display --to LOG --type INFO --nl USER_DISABLED_TEST shared_libs
return
fi
#
# First check for preloading exported variables.
#
VARFOUND=""
for RKHTMPVAR in LD_PRELOAD LD_AOUT_PRELOAD LD_ELF_PRELOAD; do
RKHTMPVAR_RES=`eval echo "\\$${RKHTMPVAR}"`
FOUND=0
for FNAME in ${RKHTMPVAR_RES}; do
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -z "`echo \"${SHARED_LIB_WHITELIST}\" | grep \" ${FNAMEGREP} \"`" ]; then
FOUND=1
else
display --to LOG --type INFO SHARED_LIBS_PRELOAD_LIB_WLIST "${FNAME}"
fi
done
if [ $FOUND -eq 1 ]; then
VARFOUND="${VARFOUND}
${RKHTMPVAR}=\"${RKHTMPVAR_RES}\""
fi
done
VARFOUND=`echo "${VARFOUND}" | sed -e '/^$/d'`
if [ -z "${VARFOUND}" ]; then
display --to SCREEN+LOG --type PLAIN --result NONE_FOUND --color GREEN --screen-indent 4 --log-indent 2 SHARED_LIBS_PRELOAD_VAR
else
display --to SCREEN+LOG --type WARNING --result WARNING --color RED --screen-indent 4 --log-indent 2 SHARED_LIBS_PRELOAD_VAR
IFS=$IFSNL
for FNAME in ${VARFOUND}; do
display --to LOG --type WARNING SHARED_LIBS_PRELOAD_VAR_FOUND "${FNAME}"
done
IFS=$RKHIFS
fi
#
# Next check for a preload file.
#
RKHTMPVAR="/etc/ld.so.preload"
if [ -s "${RKHTMPVAR}" ]; then
RKHLIBLIST=""
display --to LOG --type INFO SHARED_LIBS_PRELOAD_FILE_FOUND "${RKHTMPVAR}"
for FNAME in `cat "${RKHTMPVAR}"`; do
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -z "`echo \"${SHARED_LIB_WHITELIST}\" | grep \" ${FNAMEGREP} \"`" ]; then
RKHLIBLIST="${RKHLIBLIST} ${FNAME}"
else
display --to LOG --type INFO SHARED_LIBS_PRELOAD_LIB_WLIST "${FNAME}"
fi
done
if [ -n "${RKHLIBLIST}" ]; then
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --screen-indent 4 --log-indent 2 SHARED_LIBS_PRELOAD_FILE
for FNAME in ${RKHLIBLIST}; do
display --to LOG --type WARNING SHARED_LIBS_PRELOAD_LIB_FOUND "${FNAME}"
done
else
display --to SCREEN+LOG --type PLAIN --result WHITELISTED --color GREEN --screen-indent 4 --log-indent 2 SHARED_LIBS_PRELOAD_FILE
fi
else
display --to SCREEN+LOG --type PLAIN --result NONE_FOUND --color GREEN --screen-indent 4 --log-indent 2 SHARED_LIBS_PRELOAD_FILE
fi
#
# Finally we check the LD_LIBRARY_PATH. This check may be
# disabled by the user if the 'ldd' command is not available.
#
if `check_test shared_libs_path`; then
display --to LOG --type INFO --log-nl STARTING_TEST shared_libs_path
if [ -n "${LDD_CMD}" ]; then
if [ -n "${LD_LIBRARY_PATH}" ]; then
LD_LIBR_FAILED=0
RKHTMPVAR_BIN=""
LD_LIBRARY_PATH_SAVED="${LD_LIBRARY_PATH}"
if [ -z "${MD5_CMD}" ]; then
MD5_CMD=`find_cmd md5sum`
test -z "${MD5_CMD}" && MD5_CMD=`find_cmd md5`
fi
LS_CMD=`find_cmd ls`
for RKHTMPVAR in FIND PS STRINGS MD5 LS STAT; do
RKHTMPVAR=`eval echo "\\$${RKHTMPVAR}_CMD"`
RKHTMPVAR=`echo "${RKHTMPVAR}" | cut -d' ' -f1`
RKHTMPVAR_BIN="${RKHTMPVAR_BIN} ${RKHTMPVAR}"
done
for RKHTMPVAR in ${RKHTMPVAR_BIN}; do
LD_LIBRARY_PATH="${LD_LIBRARY_PATH_SAVED}"
export LD_LIBRARY_PATH
RKHTMPVAR_WITH=`${LDD_CMD} ${RKHTMPVAR} | sed -e 's/(0x[0-9a-f]*)/0xHEX/' 2>&1`
unset LD_LIBRARY_PATH
RKHTMPVAR_WITHOUT=`${LDD_CMD} ${RKHTMPVAR} | sed -e 's/(0x[0-9a-f]*)/0xHEX/' 2>&1`
if [ "${RKHTMPVAR_WITH}" != "${RKHTMPVAR_WITHOUT}" ]; then
#
# Testing one command should be "evidence" enough.
#
LD_LIBR_FAILED=1
break
fi
done
#
# Reset things to the way they were before.
#
LD_LIBRARY_PATH="${LD_LIBRARY_PATH_SAVED}"
export LD_LIBRARY_PATH
if [ $LD_LIBR_FAILED -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --result OK --color GREEN --screen-indent 4 --log-indent 2 SHARED_LIBS_PATH
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --screen-indent 4 --log-indent 2 SHARED_LIBS_PATH
display --to LOG --type WARNING SHARED_LIBS_PATH_BAD "${LD_LIBRARY_PATH}"
fi
else
display --to SCREEN+LOG --type PLAIN --result NOT_FOUND --color GREEN --screen-indent 4 --log-indent 2 SHARED_LIBS_PATH
fi
else
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --screen-indent 4 --log-indent 2 SHARED_LIBS_PATH
display --to LOG --type INFO NOT_FOUND_CMD 'ldd'
fi
else
display --to LOG --type INFO --nl USER_DISABLED_TEST shared_libs_path
fi
return
}
updt_rkhdat() {
#
# This function is part of the file properties check. It is
# used to add and remove entries from the rkhunter.dat file.
#
get_temp_file "${RKHTMPDIR}/rkhunter.dat"
RKHDAT_TMPFILE="${TEMPFILE}"
get_temp_file "${RKHTMPDIR}/rkhunter.dat2"
RKHDAT_TMPFILE2="${TEMPFILE}"
touch "${RKHDAT_TMPFILE}" "${RKHDAT_TMPFILE2}"
display --to LOG --type INFO CREATED_TEMP_FILE "${RKHDAT_TMPFILE}"
display --to LOG --type INFO CREATED_TEMP_FILE "${RKHDAT_TMPFILE2}"
cp -f -p "${RKHDAT_FILE}" "${RKHDAT_TMPFILE}"
IFS=$IFSNL
OLDRKHENTRIES=`echo "${OLDRKHENTRIES}" | sed -e '/^$/d'`
for FNAME in ${OLDRKHENTRIES}; do
if [ $FMTVERSION -eq 0 ]; then
FILENAME=`echo "${FNAME}" | cut -d: -f2`
else
RKH_CC=`echo "${FNAME}" | cut -d: -f2`
RKH_CC2=`expr 3 + $RKH_CC`
FILENAME=`echo "${FNAME}" | cut -d: -f3-$RKH_CC2`
fi
display --to LOG --type INFO RKHDAT_DEL_OLD_ENTRY "`name2text \"${FILENAME}\"`"
FNAMEGREP=`echo "${FNAME}" | sed -e 's:/:\\\/:g'`
sed -e "/^${FNAMEGREP}$/d" "${RKHDAT_TMPFILE}" >"${RKHDAT_TMPFILE2}"
cp -f "${RKHDAT_TMPFILE2}" "${RKHDAT_TMPFILE}"
done
NEWRKHENTRIES=`echo "${NEWRKHENTRIES}" | sed -e '/^$/d'`
for FNAME in ${NEWRKHENTRIES}; do
if [ $FMTVERSION -eq 0 ]; then
FILENAME=`echo "${FNAME}" | cut -d: -f2`
else
RKH_CC=`echo "${FNAME}" | cut -d: -f2`
RKH_CC2=`expr 3 + $RKH_CC`
FILENAME=`echo "${FNAME}" | cut -d: -f3-$RKH_CC2`
fi
display --to LOG --type INFO RKHDAT_ADD_NEW_ENTRY "`name2text \"${FILENAME}\"`"
echo "${FNAME}" >>"${RKHDAT_TMPFILE}"
done
IFS=$RKHIFS
#
# Now put the new rkhunter.dat file in place.
#
cp -f -p "${RKHDAT_FILE}" "${RKHDAT_FILE}.old" >/dev/null 2>&1
cp -f "${RKHDAT_TMPFILE}" "${RKHDAT_FILE}" >/dev/null 2>&1
ERRCODE=$?
if [ $ERRCODE -ne 0 ]; then
RET_CODE=1
display --to LOG --type INFO CMD_ERROR "cp ${RKHDAT_TMPFILE} ${RKHDAT_FILE}" $ERRCODE
display --to SCREEN+LOG --type WARNING PROPUPD_ERROR $ERRCODE
else
display --to LOG --type INFO PROPUPD_NEW_DAT_FILE "${DB_PATH}"
fi
chmod 640 "${RKHDAT_FILE}" >/dev/null 2>&1
rm -f "${RKHDAT_TMPFILE}" "${RKHDAT_TMPFILE2}" >/dev/null 2>&1
return
}
file_properties_check() {
#
# This function carries out a check of system command property
# values checked against their previous value, which is stored
# in the rkhunter.dat file. Other checks work on the current
# file, and do not use any previously stored value (for example,
# the immutable-bit check).
#
#
# Each test will set the variable TEST_RESULT, and use it to
# display the actual result. Typically a null string indicates
# 'OK', and anything else is a 'Warning'.
#
TEST_RESULT=""
NEWRKHENTRIES=""
OLDRKHENTRIES=""
WHITELIST_RESULT=""
SKIP_ATTR=0; SKIP_HASH=0; SKIP_IMMUT=0; SKIP_SCRIPT=0
USE_DAT_FILE=1
SKIP_IMMUT_OS=0
PROP_FILE_LIST_COUNT=0
ADDNEWENTRY=0
#
# In order to disable the whole test we have to check if
# each specific test has been disabled.
#
for RKHTMPVAR in attributes hashes immutable scripts; do
if ! `check_test ${RKHTMPVAR}`; then
case "${RKHTMPVAR}" in
attributes)
SKIP_ATTR=1
;;
hashes)
SKIP_HASH=1
;;
immutable)
SKIP_IMMUT=1
;;
scripts)
SKIP_SCRIPT=1
;;
esac
fi
done
#
# The immutable-bit test is only applicable to Linux and
# BSD systems. We need to disable the test, but not have
# it logged as if the user had disabled it (that would be
# confusing).
#
if [ $BSDOS -eq 0 -a $LINUXOS -eq 0 ]; then
if [ $SKIP_IMMUT -eq 0 ]; then
SKIP_IMMUT=1
SKIP_IMMUT_OS=1
fi
fi
if ! `check_test properties`; then
display --to LOG --type INFO --nl USER_DISABLED_TEST properties
return
elif [ $SKIP_ATTR -eq 1 -a $SKIP_HASH -eq 1 -a $SKIP_IMMUT -eq 1 -a $SKIP_SCRIPT -eq 1 ]; then
display --to LOG --type INFO --nl USER_DISABLED_TEST properties
return
else
display --to LOG --type INFO --screen-nl --nl STARTING_TEST properties
display --to SCREEN+LOG --type PLAIN --screen-indent 2 FILE_PROP_START
fi
#
# If the user wants to skip a test then log it.
#
for RKHTMPVAR in attributes hashes immutable scripts; do
case "${RKHTMPVAR}" in
attributes)
TEST_NAME=$SKIP_ATTR
;;
hashes)
TEST_NAME=$SKIP_HASH
;;
scripts)
TEST_NAME=$SKIP_SCRIPT
;;
immutable)
TEST_NAME=0
test $SKIP_IMMUT_OS -eq 0 && TEST_NAME=$SKIP_IMMUT
;;
esac
test $TEST_NAME -eq 1 && display --to LOG --type INFO USER_DISABLED_TEST ${RKHTMPVAR}
done
#
# The first test we do is on the commands needed to
# perform all the file checks. If the user has not
# disabled any test, and a command is missing, then
# we must let them know that without marking each file
# test as a 'Warning' (because that could hide a real
# problem). We include checks on the rkhunter.dat file
# as well.
#
RKHTMPVAR=""
if [ $SKIP_ATTR -eq 0 -a -z "${STAT_CMD}" ]; then
SKIP_ATTR=1
RKHTMPVAR="${RKHTMPVAR} attr"
fi
if [ $SKIP_HASH -eq 0 ]; then
# Not sure about this one...!
if [ -z "${OLD_PKGMGR}" -a -s ${RKHDAT_FILE} -a "${HASH_FUNC}" != "NONE" -a \( "${OLD_HASH_FUNC}" = "NONE" -o "${OLD_HASH_FUNC}" = "Disabled" -o -z "${OLD_HASH_FUNC}" \) ]; then
SKIP_HASH=1
RKHTMPVAR="${RKHTMPVAR} hash"
if [ -n "${PRELINK_HASH}" ]; then
HASH_FUNC_ERR="prelink with ${PRELINK_HASH}"
else
HASH_FUNC_ERR="${HASH_FUNC}"
fi
if [ -z "${OLD_HASH_FUNC}" ]; then
OLD_HASH_FUNC_ERR="Unset"
else
if [ "${OLD_HASH_FUNC}" = "MD5" -o "${OLD_HASH_FUNC}" = "SHA1" ]; then
OLD_HASH_FUNC_ERR="prelink with ${OLD_HASH_FUNC}"
else
OLD_HASH_FUNC_ERR="${OLD_HASH_FUNC}"
fi
fi
if [ -z "${PKGMGR}" ]; then
PKGMGR_ERR="Unset"
else
PKGMGR_ERR="${PKGMGR}"
fi
if [ -z "${OLD_PKGMGR}" ]; then
OLD_PKGMGR_ERR="Unset"
else
OLD_PKGMGR_ERR="${OLD_PKGMGR}"
fi
fi
if [ $SKIP_HASH_MSG -eq 1 ]; then
SKIP_HASH=1
RKHTMPVAR="${RKHTMPVAR} sha1"
elif [ $SKIP_HASH_MSG -eq 2 ]; then
SKIP_HASH=1
RKHTMPVAR="${RKHTMPVAR} libsafe"
fi
fi
if [ $SKIP_IMMUT -eq 0 ]; then
if [ $BSDOS -eq 1 ]; then
if [ -z "`ls -lno ${CONFIGFILE} 2>/dev/null`" ]; then
SKIP_IMMUT=1
RKHTMPVAR="${RKHTMPVAR} immutable-bsd"
fi
else
if [ -z "${LSATTR_CMD}" ]; then
SKIP_IMMUT=1
RKHTMPVAR="${RKHTMPVAR} immutable"
else
for FNAME in ${CONFIGFILE} ${LOCALCONFIGFILE} ${LOCALCONFDIRFILES} ${DB_PATH}/*.dat ${DB_PATH}/i18n/*; do
test -f "${FNAME}" -a ! -h "${FNAME}" && break
done
if [ -z "`${LSATTR_CMD} \"${FNAME}\" 2>/dev/null`" ]; then
SKIP_IMMUT=1
RKHTMPVAR="${RKHTMPVAR} immutable-cmd"
fi
fi
fi
fi
if [ $SKIP_SCRIPT -eq 0 ]; then
if [ -z "${FILE_CMD}" ]; then
SKIP_SCRIPT=1
RKHTMPVAR="${RKHTMPVAR} script"
elif [ -z "`${FILE_CMD} \"${CONFIGFILE}\" 2>/dev/null`" ]; then
SKIP_SCRIPT=1
RKHTMPVAR="${RKHTMPVAR} script-cmd"
fi
fi
if [ $SKIP_ATTR -eq 0 -o $SKIP_HASH -eq 0 ]; then
if [ ! -f "${RKHDAT_FILE}" ]; then
SKIP_HASH=1
SKIP_ATTR=1
USE_DAT_FILE=0
RKHTMPVAR="${RKHTMPVAR} missing"
fi
if [ $USE_DAT_FILE -eq 1 -a ! -s ${RKHDAT_FILE} ]; then
SKIP_HASH=1
SKIP_ATTR=1
USE_DAT_FILE=0
RKHTMPVAR="${RKHTMPVAR} empty"
fi
else
#
# If we are not checking the file attributes or
# the hash value, then we don't need to look at
# the rkhunter.dat file. The other tests can be
# done without the file.
#
USE_DAT_FILE=0
fi
#
# If the O/S has changed in some way, and we are not just reporting warnings,
# and O/S warnings are enabled, then show a warning in the prerequisites test.
#
if [ $OS_CHANGED -eq 1 -a $SHOWWARNINGSONLY -eq 0 -a $WARN_ON_OS_CHANGE -eq 1 ]; then
RKHTMPVAR="${RKHTMPVAR} os_changed"
fi
#
# If all the previous checks have disabled all the tests,
# then we tell the user and then return.
#
if [ $SKIP_ATTR -eq 1 -a $SKIP_HASH -eq 1 -a $SKIP_IMMUT -eq 1 -a $SKIP_SCRIPT -eq 1 ]; then
RKHTMPVAR="${RKHTMPVAR} notests"
fi
#
# Display the results.
#
if [ $SKIP_IMMUT_OS -eq 1 ]; then
display --to LOG --type INFO FILE_PROP_IMMUT_OS
fi
if [ $IMMUTABLE_SET -eq 1 ]; then
display --to LOG --type INFO FILE_PROP_IMMUT_SET
fi
if [ -z "${RKHTMPVAR}" ]; then
display --to SCREEN+LOG --type PLAIN --screen-indent 4 --log-indent 2 --result OK --color GREEN FILE_PROP_CMDS
else
SUMMARY_PROP_REQCMDS=1
display --to SCREEN+LOG --type WARNING --screen-indent 4 --log-indent 2 --result WARNING --color RED FILE_PROP_CMDS
RKHTMPVAR2=0
for TEST_RESULT in ${RKHTMPVAR}; do
case "${TEST_RESULT}" in
attr)
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_SKIP_ATTR
;;
hash|prelink|sha1|libsafe)
if [ $RKHTMPVAR2 -eq 0 ]; then
RKHTMPVAR2=1
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_SKIP_HASH
fi
case "${TEST_RESULT}" in
hash)
display --to LOG --type PLAIN --log-indent 13 FILE_PROP_SKIP_HASH_FUNC "${HASH_FUNC_ERR}" "${PKGMGR_ERR}" "${OLD_HASH_FUNC_ERR}" "${OLD_PKGMGR_ERR}"
;;
prelink)
display --to LOG --type PLAIN --log-indent 13 FILE_PROP_SKIP_HASH_PRELINK
;;
sha1)
display --to LOG --type PLAIN --log-indent 13 FILE_PROP_SKIP_HASH_SHA1
;;
libsafe)
display --to LOG --type PLAIN --log-indent 13 FILE_PROP_SKIP_HASH_LIBSAFE
;;
esac
;;
immutable)
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_SKIP_IMMUT
;;
immutable-bsd)
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_SKIP_IMMUT_CMD 'ls -lno'
;;
immutable-cmd)
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_SKIP_IMMUT_CMD 'lsattr'
;;
script)
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_SKIP_SCRIPT
;;
script-cmd)
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_SKIP_FILE_CMD
;;
os_changed)
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_OS_CHANGED
;;
missing)
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_DAT_MISSING
display --to LOG --type INFO FILE_PROP_DAT_MISSING_INFO
;;
empty)
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_DAT_EMPTY
display --to LOG --type INFO FILE_PROP_DAT_MISSING_INFO
;;
esac
done
if [ -n "`echo \"${RKHTMPVAR}\" | egrep 'libsafe|missing|empty'`" ]; then
display --to LOG --type WARNING --nl PROPUPD_WARN
fi
if [ -n "`echo \"${RKHTMPVAR}\" | grep 'notests'`" ]; then
display --to LOG --type WARNING --nl FILE_PROP_SKIP_ALL
return
fi
fi
#
# Set up some local variables depending on what
# commands we have available.
#
if [ $SKIP_ATTR -eq 1 ]; then
SCMD=""
INODECMD=""
else
if [ -n "`echo \"${STAT_CMD}\" | grep '\.pl$'`" ]; then
if [ "${PKGMGR}" = "SOLARIS" ]; then
SCMD="${STAT_CMD} --modeoct --raw --ino --mode --uid --gid --size --mtime"
else
SCMD="${STAT_CMD} --modeoct --raw --ino --mode --uid --gid --size --Mtime"
fi
INODECMD="${STAT_CMD} --modeoct --raw --ino"
elif [ $BSDOS -eq 1 -o $MACOSX -eq 1 ]; then
SCMD="${STAT_CMD} -f '%i %Mp%Lp %u %g %z %m:'"
INODECMD="${STAT_CMD} -f '%i'"
else
SCMD="${STAT_CMD} -c '%i 0%a %u %g %s %Y:'"
INODECMD="${STAT_CMD} -c '%i'"
fi
fi
if [ $SKIP_HASH -eq 1 ]; then
SYSHASH=""
HASH_CMD=""
else
HASH_CMD="${HASH_FUNC}"
fi
#
# Next we have to recreate the list of pathnames for the
# file properties checks. We need to recreate it because
# the root PATH may have changed, and so there may be more
# directories to be checked. However, if we have just run
# the '--propupd' option, then we can skip this.
#
test $PROP_UPDATE -eq 0 && create_rkh_file_prop_list
#
# We need the current 'rkhunter.dat' file format.
#
if [ $USE_DAT_FILE -eq 1 ]; then
FMTVERSION=`grep '^FormatVersion:' "${RKHDAT_FILE}" | cut -d: -f2`
test -z "${FMTVERSION}" && FMTVERSION=0
else
FMTVERSION=0
fi
#
# Now loop through each of the files and perform the tests on each one.
#
# We must set IFS around this loop, otherwise any names in the file
# properties list containing whitespace will be separated out.
# However, because IFS interacts with some commands, executed via
# backticks, we must then reset IFS for the duration of the loop
# and set it again at the end of the loop. It's messy, but it works.
#
IFS=$IFSNL
VERIFIED_PKG_LIST=""
for FNAME in `cat "${RKH_FILEPROP_LIST}"`; do
SYSLNK=""
FILENAME=""
FNAMEGREP=""
TEST_RESULT=""
WHITELIST_RESULT=""
RKH_CC=0
SYSLNK_CC=0
NOVRFYFILE=0
ADDNEWENTRY=0
COLON_COUNT=0
FILE_IS_PKGD=0
DEPENDENCY_ERR=0
HASH_TEST_PASSED=0
SIZE_TEST_PASSED=0
IFS=$RKHIFS
#
# We first need to test if the file exists or not,
# and if the file is listed in the rkhunter.dat
# file or not. This can indicate files that have
# appeared on or disappeared from the system.
#
FNAME=`echo "${FNAME}" | sed -e 's/^"\(.*\)"$/\1/'`
if [ -f "${FNAME}" -o -h "${FNAME}" ]; then
FILE_EXISTS=1
PROP_FILE_LIST_COUNT=`expr ${PROP_FILE_LIST_COUNT} + 1`
else
FILE_EXISTS=0
fi
if [ $USE_DAT_FILE -eq 1 ]; then
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ $FMTVERSION -eq 0 ]; then
RKHLINE=`grep "^File:${FNAMEGREP}:" "${RKHDAT_FILE}"`
else
COLON_COUNT=`echo "${FNAME}" | tr -c -d ':' | wc -c | tr -d ' '`
RKHLINE=`grep "^File:${COLON_COUNT}:${FNAMEGREP}:" "${RKHDAT_FILE}"`
fi
if [ $FILE_EXISTS -eq 1 -a -z "${RKHLINE}" ]; then
if [ -n "`echo \"${EXISTWHITELIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
#
# We need to add the file to the rkhunter.dat file.
# We add a dummy entry to start with, but it must contain values.
#
ADDNEWENTRY=1
if [ -h "${FNAME}" -a $HAVE_READLINK -eq 1 ]; then
SYSLNK=`${READLINK_CMD} -f "${FNAME}"`
fi
if [ $FMTVERSION -eq 0 ]; then
RKHLINE="File:${FNAME}:1:1:1:1:1:1:1::${SYSLNK}:"
else
SYSLNK_CC=`echo "${SYSLNK}" | tr -c -d ':' | wc -c | tr -d ' '`
RKHLINE="File:${COLON_COUNT}:${FNAME}:1:1:1:1:1:1:1::${SYSLNK_CC}:${SYSLNK}:"
fi
else
TEST_RESULT="${TEST_RESULT} norkhline"
fi
elif [ $FILE_EXISTS -eq 0 ]; then
if [ -n "`echo \"${EXISTWHITELIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
if [ -n "${RKHLINE}" ]; then
#
# We need to remove the file from the rkhunter.dat file.
#
OLDRKHENTRIES="${OLDRKHENTRIES}
${RKHLINE}"
fi
elif [ -n "${RKHLINE}" ]; then
PROP_FAILED_COUNT=`expr ${PROP_FAILED_COUNT} + 1`
display --to SCREEN+LOG --type PLAIN --screen-indent 4 --log-indent 2 --result WARNING --color RED NAME "`name2text \"${FNAME}\"`"
display --to LOG --type WARNING FILE_PROP_FILE_NOT_EXIST "`name2text \"${FNAME}\"`"
fi
IFS=$IFSNL
continue
fi
elif [ $FILE_EXISTS -eq 1 ]; then
RKHLINE=""
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
else
IFS=$IFSNL
continue
fi
#
# Start the tests.
#
SYSUID=0
SYSGID=0
SYSDTM=0
SYSSIZE=0
SYSPERM=0
SYSINODE=0
RKHLNK=""
SYSHASH=""
if [ $USE_DAT_FILE -eq 1 -a -n "${RKHLINE}" ]; then
FDATA=""
RPM_QUERY_RESULT=""
PKGMGR_VERIFY_RESULT=""
#
# We need to calculate if the filename (in the file) has any colons in it.
# We then set RKH_CC to point to the field after the filename (the hash field).
#
if [ $FMTVERSION -eq 0 ]; then
RKH_CC=3
else
RKH_CC=`echo "${RKHLINE}" | cut -d: -f2`
RKH_CC=`expr 4 + $RKH_CC`
fi
#
# See if the file is to be exempt from any package manager verification.
#
if [ -n "`echo \"${PKGMGRNOVRFY}\" | grep \"^${FNAMEGREP}$\"`" ]; then
NOVRFYFILE=1
fi
#
# Because the RPM package manager can verify most of the tests we are
# doing, we obtain the verified data now. The Solaris package manager
# provides some data, but does not verify it against the values on disk.
# With all the package managers we have to obtain unverified data by
# using commands. The other package managers, at present, only provide
# the MD5 checksum. As such we simply handle them within the hash test.
#
if [ "${PKGMGR}" = "RPM" ]; then
#
# First we see if the file is exempt or part of a package.
#
if [ $NOVRFYFILE -eq 0 ]; then
PKGNAME_ARCH=`${RPM_CMD} -qf "${FNAME}" --queryformat '%{N}-%{V}-%{R}.%{ARCH}\n' 2>/dev/null`
ERRCODE=$?
if [ $ERRCODE -eq 0 ]; then
#
# Okay we have a package name. Is it in the list
# of packages we have already tested as verified?
#
# If multiple packages claim the same file, we use
# 64-bit over 32-bit, or simply the last one.
#
FILE_IS_PKGD=1
PKGNAME=`echo "${PKGNAME_ARCH}" | egrep '\.(x86_64|ia64)$' | tail ${TAIL_OPT}1`
test -z "${PKGNAME}" && PKGNAME=`echo "${PKGNAME_ARCH}" | tail ${TAIL_OPT}1`
RKHTMPVAR=`echo "${PKGNAME}" | sed -e 's/\./\\\./g'`
if [ -z "`echo \"${VERIFIED_PKG_LIST}\" | grep \" ${RKHTMPVAR} \"`" ]; then
#
# No, it isn't in the list. So we verify the package
# and either add it to the list if it verifies okay,
# or get the verification result for the file.
#
PKGMGR_VERIFY_RESULT=`${RPM_CMD} -V "${PKGNAME}" 2>&1`
if [ -z "${PKGMGR_VERIFY_RESULT}" ]; then
VERIFIED_PKG_LIST="${VERIFIED_PKG_LIST} ${PKGNAME} "
else
if [ -n "`echo \"${PKGMGR_VERIFY_RESULT}\" | grep \"prelink.* ${FNAME}.* dependenc\"`" ]; then
DEPENDENCY_ERR=1
fi
PKGMGR_VERIFY_RESULT=`echo "${PKGMGR_VERIFY_RESULT}" | grep " ${FNAMEGREP}\$" | cut -d' ' -f1`
fi
fi
#
# The package manager check does not verify all the items
# we check. So we still need to dig out the rest of the
# information about this file from the package manager database.
# Note that the filenames are displayed at the end of the rpm output.
# This means that any filename containing a colon will not cause
# a problem.
#
RPM_QUERY_RESULT=`${RPM_CMD} -q --queryformat '[%{FILEMODES:octal}:%{FILEUSERNAME}:%{FILEGROUPNAME}:%{FILESIZES}:%{FILEMTIMES}:%{FILEMD5S}:%{FILELINKTOS}:%{FILENAMES}\n]' "${PKGNAME}" 2>/dev/null | grep ":${FNAMEGREP}\$"`
ERRCODE=$?
#
# The error code actually refers to the 'grep' command above. If the
# file is not found in the package, then this is probably due to the
# 'bin' directory being a link. So we change the filename, and retest.
#
if [ $ERRCODE -eq 1 -a $BINISLINK -eq 1 ]; then
if [ -n "`echo \"${FNAME}\" | grep '^\/usr\/'`" ]; then
RKHTMPVAR3=`echo "${FNAMEGREP}" | sed -e 's:^/usr::'`
else
RKHTMPVAR3="/usr${FNAMEGREP}"
fi
RPM_QUERY_RESULT=`${RPM_CMD} -q --queryformat '[%{FILEMODES:octal}:%{FILEUSERNAME}:%{FILEGROUPNAME}:%{FILESIZES}:%{FILEMTIMES}:%{FILEMD5S}:%{FILELINKTOS}:%{FILENAMES}\n]' "${PKGNAME}" 2>/dev/null | grep ":${RKHTMPVAR3}\$"`
ERRCODE=$?
fi
if [ $ERRCODE -eq 0 ]; then
RPM_QUERY_RESULT=`echo "${RPM_QUERY_RESULT}" | tail ${TAIL_OPT}1`
FPERM="0`echo \"${RPM_QUERY_RESULT}\" | cut -d: -f1 | cut -c 3-`"
FPERM=`echo "${FPERM}" | sed -e 's/^00/0/'`
RKHUID=`echo "${RPM_QUERY_RESULT}" | cut -d: -f2`
RKHUID=`grep "^${RKHUID}:" /etc/passwd 2>/dev/null | cut -d: -f3`
RKHGID=`echo "${RPM_QUERY_RESULT}" | cut -d: -f3`
RKHGID=`grep "^${RKHGID}:" /etc/group 2>/dev/null | cut -d: -f3`
RKHSIZE=`echo "${RPM_QUERY_RESULT}" | cut -d: -f4`
RKHDTM=`echo "${RPM_QUERY_RESULT}" | cut -d: -f5`
if [ -h "${FNAME}" ]; then
RKHLNK=`echo "${RPM_QUERY_RESULT}" | cut -d: -f7`
if [ -z "`echo \"${RKHLNK}\" | grep '^/'`" ]; then
test -n "${DIRNAME_CMD}" && DIR=`${DIRNAME_CMD} "${FNAME}"` || DIR=`echo "${FNAME}" | sed -e 's:/[^/]*$::'`
RKHLNK="${DIR}/${RKHLNK}"
fi
# This ensures the link target has things like '..' removed.
test $HAVE_READLINK -eq 1 && RKHLNK=`${READLINK_CMD} -f "${RKHLNK}"`
fi
FDATA="${FPERM}:${RKHUID}:${RKHGID}:${RKHSIZE}:${RKHDTM}:"
else
#
# If, for some reason, we cannot get the package information,
# then treat it as if it returned all null values.
#
FDATA=":::::"
display --to LOG --type INFO CMD_ERROR "rpm -qf --queryformat... \"${FNAME}\" (${PKGNAME})" $ERRCODE
fi
#
# Now get the inode value directly from the disk,
# but only if prelinking is not being used.
#
RKHTMPVAR=""
if [ $PRELINKED -eq 0 -a -n "${INODECMD}" ]; then
RKHTMPVAR=`eval ${INODECMD} "\"${FNAME}\"" 2>/dev/null | tr -d ' '`
fi
FDATA="${RKHTMPVAR}:${FDATA}"
fi
fi
elif [ "${PKGMGR}" = "SOLARIS" ]; then
#
# First we see if the file is exempt or part of a package.
#
if [ $NOVRFYFILE -eq 1 ]; then
ERRCODE=1
else
RKHTMPVAR=`grep "^${FNAMEGREP} " /var/sadm/install/contents 2>/dev/null`
test -n "${RKHTMPVAR}" && ERRCODE=0 || ERRCODE=1
fi
if [ $ERRCODE -eq 0 ]; then
#
# We will rebuild the RKHLINE value with the values from
# the package manager database. We can then verify it just
# as if it had been read from the RKH database.
#
FPERM=`echo "${RKHTMPVAR}" | cut -d' ' -f4`
RKHUID=`echo "${RKHTMPVAR}" | cut -d' ' -f5`
RKHUID=`grep "^${RKHUID}:" /etc/passwd 2>/dev/null | cut -d: -f3`
RKHGID=`echo "${RKHTMPVAR}" | cut -d' ' -f6`
RKHGID=`grep "^${RKHGID}:" /etc/group 2>/dev/null | cut -d: -f3`
RKHSIZE=`echo "${RKHTMPVAR}" | cut -d' ' -f7`
if [ $USE_SUNSUM -eq 1 ]; then
# Treat this as a fully packaged file.
FILE_IS_PKGD=1
RKHHASH=`echo "${RKHTMPVAR}" | cut -d' ' -f8`
else
RKHHASH=`echo "${RKHLINE}" | cut -d: -f$RKH_CC`
fi
RKHDTM=`echo "${RKHTMPVAR}" | cut -d' ' -f9`
#
# Now get the inode value.
#
RKHTMPVAR=""
test -n "${INODECMD}" && RKHTMPVAR=`eval ${INODECMD} "\"${FNAME}\"" 2>/dev/null | tr -d ' '`
#
# Finally, get the file name. To do this we adjust RKH_CC back one field.
#
RKH_CC2=`expr $RKH_CC - 1`
RKHTMPVAR2=`echo "${RKHLINE}" | cut -d: -f1-$RKH_CC2`
#
# Now put it all together.
#
RKHLINE="${RKHTMPVAR2}:${RKHHASH}:${RKHTMPVAR}:${FPERM}:${RKHUID}:${RKHGID}:${RKHSIZE}:${RKHDTM}"
fi
fi
#
# Do the file hash value check.
#
if [ $SKIP_HASH -eq 0 ]; then
#
# First we get all the package manager results.
#
case "${PKGMGR}" in
RPM)
;;
DPKG)
#
# First see if the file is exempt or part of a known package.
#
if [ $NOVRFYFILE -eq 1 ]; then
PKGNAME=""
else
PKGNAME=`${DPKG_CMD} --search "${FNAME}" 2>/dev/null | cut -d: -f1`
fi
if [ -n "${PKGNAME}" -a -f "/var/lib/dpkg/info/${PKGNAME}.md5sums" ]; then
FNGREP=`echo "${FNAMEGREP}" | sed -e 's:^/::'`
SYSHASH=`egrep "( |\./)${FNGREP}\$" "/var/lib/dpkg/info/${PKGNAME}.md5sums" | cut -d' ' -f1`
if [ -n "${SYSHASH}" ]; then
FILE_IS_PKGD=1
RKHTMPVAR=`${PKGMGR_MD5_HASH} "${FNAME}" 2>/dev/null | cut -d' ' -f $HASH_FLD_IDX`
if [ "${RKHTMPVAR}" != "${SYSHASH}" ]; then
PKGMGR_VERIFY_RESULT="5"
if [ -n "`${PKGMGR_MD5_HASH} "${FNAME}" 2>&1 | egrep 'prelink.* (dependenc|adjusting unfinished)'`" ]; then
DEPENDENCY_ERR=1
fi
fi
fi
fi
;;
BSD)
#
# First see if the file is exempt or part of a known package.
#
if [ $NOVRFYFILE -eq 1 ]; then
PKGNAME=""
else
PKGNAME=`${PKG_CMD} -F -e "${FNAME}" 2>/dev/null`
fi
if [ -n "${PKGNAME}" ]; then
#
# Next strip off the '/usr/pkg' from the
# pathname, and then get the hash value.
#
FNGREP=`echo "${FNAMEGREP}" | sed -e 's:^/usr/pkg/::'`
SYSHASH=`${PKG_CMD} -v -L "${PKGNAME}" 2>/dev/null | grep -A 1 "File: ${FNGREP}\$" | tail ${TAIL_OPT}1 | cut -d: -f3`
if [ -n "${SYSHASH}" ]; then
FILE_IS_PKGD=1
RKHTMPVAR=`${PKGMGR_MD5_HASH} "${FNAME}" 2>/dev/null | cut -d' ' -f $HASH_FLD_IDX`
if [ "${RKHTMPVAR}" != "${SYSHASH}" ]; then
PKGMGR_VERIFY_RESULT="5"
if [ -n "`${PKGMGR_MD5_HASH} "${FNAME}" 2>&1 | egrep 'prelink.* (dependenc|adjusting unfinished)'`" ]; then
DEPENDENCY_ERR=1
fi
fi
fi
fi
;;
SOLARIS)
#
# We only use the Solaris package manager
# hash value if we have been told to do so.
#
if [ $NOVRFYFILE -eq 0 -a $USE_SUNSUM -eq 1 ]; then
SYSHASH="${RKHHASH}"
RKHTMPVAR=`${SUM_CMD} "${FNAME}" 2>/dev/null | cut -d' ' -f $HASH_FLD_IDX`
if [ "${RKHTMPVAR}" != "${SYSHASH}" ]; then
PKGMGR_VERIFY_RESULT="5"
fi
fi
;;
esac
#
# Now see if we need to work out the hash value or not.
#
RKHHASH=`echo "${RKHLINE}" | cut -d: -f$RKH_CC`
if [ $FILE_IS_PKGD -eq 1 ]; then
if [ "${RKHHASH}" = "ignore-prelink-dep-err" ]; then
if [ $DEPENDENCY_ERR -eq 1 ]; then
DEPENDENCY_ERR=0
PKGMGR_VERIFY_RESULT=""
display --to LOG --type INFO FILE_PROP_IGNORE_PRELINK_DEP_ERR "`name2text \"${FNAME}\"`"
else
PKGMGR_VERIFY_RESULT="5"
fi
fi
if [ -z "`echo \"${PKGMGR_VERIFY_RESULT}\" | egrep '5|(^..\?)'`" ]; then
HASH_TEST_PASSED=1
else
TEST_RESULT="${TEST_RESULT} verify:hashchanged"
fi
else
#
# The file is not part of a package. So we need
# to compare the on-disk hash value against the
# value in the rkhunter.dat file.
#
# First see if we have a stored hash value.
#
RKHTMPVAR=0
if [ -z "${RKHHASH}" ]; then
if [ "${HASH_CMD}" = "NONE" ]; then
:
else
#
# Broken links may not give a hash value, so we must check to see if the link is whitelisted.
#
if [ -h "${FNAME}" -a $HAVE_READLINK -eq 1 ]; then
# Check the link target to see if it is whitelisted.
if [ -z "${SYSLNK}" ]; then
SYSLNK=`${READLINK_CMD} -f "${FNAME}"`
fi
FNGREP=`echo "${SYSLNK}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -n "`echo \"${EXISTWHITELIST}\" | grep \"^${FNGREP}$\"`" ]; then
RKHTMPVAR=1
if [ ! -e "${FNAME}" -a $VERBOSE_LOGGING -eq 1 ]; then
# Only log this if it is a broken link.
display --to LOG --type INFO FILE_PROP_BROKEN_LINK_WL_TGT "`name2text \"${FNAME}\"`" "`name2text \"${SYSLNK}\"`"
fi
fi
fi
test $RKHTMPVAR -eq 0 && TEST_RESULT="${TEST_RESULT} norkhhash"
fi
fi
if [ $RKHTMPVAR -eq 0 -a -z "${TEST_RESULT}" ]; then
if [ "${HASH_CMD}" = "NONE" ]; then
SYSHASH=""
else
SYSHASH=`${HASH_CMD} "${FNAME}" 2>/dev/null | cut -d' ' -f $HASH_FLD_IDX`
if [ -z "${SYSHASH}" ]; then
if [ -n "`${HASH_CMD} "${FNAME}" 2>&1 | egrep 'prelink.* (dependenc|adjusting unfinished)'`" ]; then
if [ "${RKHHASH}" = "ignore-prelink-dep-err" ]; then
SYSHASH="${RKHHASH}"
display --to LOG --type INFO FILE_PROP_IGNORE_PRELINK_DEP_ERR "`name2text \"${FNAME}\"`"
else
DEPENDENCY_ERR=1
fi
fi
fi
fi
if [ "${RKHHASH}" != "${SYSHASH}" ]; then
#
# We must test for cases where a symbolic link becomes broken. In those
# cases the link would have had a hash value, but will now have none.
# If it was whitelisted, then we should not give a warning.
#
if [ -h "${FNAME}" -a ! -e "${FNAME}" ]; then
if [ $HAVE_READLINK -eq 1 ]; then
# Check the link target to see if it is whitelisted.
if [ -z "${SYSLNK}" ]; then
SYSLNK=`${READLINK_CMD} -f "${FNAME}"`
fi
FNGREP=`echo "${SYSLNK}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -n "`echo \"${EXISTWHITELIST}\" | grep \"^${FNGREP}$\"`" ]; then
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type INFO FILE_PROP_BROKEN_LINK_WL_TGT "`name2text \"${FNAME}\"`" "`name2text \"${SYSLNK}\"`"
fi
else
TEST_RESULT="${TEST_RESULT} hashchanged"
fi
else
TEST_RESULT="${TEST_RESULT} hashchanged"
fi
else
TEST_RESULT="${TEST_RESULT} hashchanged"
fi
fi
fi
fi
#
# Because the BSD and DPKG package managers only provide the MD5
# checksum, and the Solaris package manager does not provide verified
# data, we can assume that any file which is part of a package after
# this test must be an RPM file.
#
test "${PKGMGR}" != "RPM" && FILE_IS_PKGD=0
fi
#
# Do the file attributes checks.
#
# This checks the files permissions, and the uid/gid.
# The file permissions are also checked to see if 'w'
# has been allowed for all users. If prelinking is not
# in use then the inode, file size, and modification
# date-time are checked as well.
#
if [ $SKIP_ATTR -eq 0 ]; then
#
# First check to see if the file is whitelisted here,
# just the once. It is better than checking after
# each individual attribute test.
#
WL_FILE=""
if [ -n "`echo \"${ATTRWHITELIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
WL_FILE="whitelisted"
WHITELIST_RESULT="${WHITELIST_RESULT} attr"
fi
if [ -z "${FDATA}" ]; then
FDATA=`eval ${SCMD} "\"${FNAME}\"" 2>/dev/null | tr ' ' ':'`
# Ensure the file permissions consist of only 4 digits.
if [ -n "`echo ${FDATA} | grep '^[^:]*:0[0-9][0-9][0-9][0-9]:'`" ]; then
FDATA=`echo $FDATA | sed -e 's/^\([^:]*:\)0\(.*\)$/\1\2/'`
fi
fi
if [ -z "${WL_FILE}" -a -n "${FDATA}" ]; then
#
# Check the file permissions.
#
if [ $FILE_IS_PKGD -eq 1 ]; then
echo "${PKGMGR_VERIFY_RESULT}" | egrep 'M|(^.\?)' >/dev/null && TEST_RESULT="${TEST_RESULT} verify:permchanged"
else
RKH_CC2=`expr $RKH_CC + 2`
RKHPERM=`echo ${RKHLINE} | cut -d: -f$RKH_CC2`
SYSPERM=`echo ${FDATA} | cut -d: -f2`
if [ -n "${RKHPERM}" ]; then
test "${RKHPERM}" != "${SYSPERM}" && TEST_RESULT="${TEST_RESULT} permchanged"
else
TEST_RESULT="${TEST_RESULT} norkhperm"
fi
fi
#
# Check the file user-id.
#
if [ $FILE_IS_PKGD -eq 1 ]; then
echo "${PKGMGR_VERIFY_RESULT}" | egrep 'U|(^.....\?)' >/dev/null && TEST_RESULT="${TEST_RESULT} verify:uidchanged"
else
RKH_CC2=`expr $RKH_CC + 3`
RKHUID=`echo ${RKHLINE} | cut -d: -f$RKH_CC2`
SYSUID=`echo ${FDATA} | cut -d: -f3`
if [ -n "${RKHUID}" ]; then
test "${RKHUID}" != "${SYSUID}" && TEST_RESULT="${TEST_RESULT} uidchanged"
else
TEST_RESULT="${TEST_RESULT} norkhuid"
fi
fi
#
# Check the file group-id.
#
if [ $FILE_IS_PKGD -eq 1 ]; then
echo "${PKGMGR_VERIFY_RESULT}" | egrep 'G|(^......\?)' >/dev/null && TEST_RESULT="${TEST_RESULT} verify:gidchanged"
else
RKH_CC2=`expr $RKH_CC + 4`
RKHGID=`echo ${RKHLINE} | cut -d: -f$RKH_CC2`
SYSGID=`echo ${FDATA} | cut -d: -f4`
if [ -n "${RKHGID}" ]; then
test "${RKHGID}" != "${SYSGID}" && TEST_RESULT="${TEST_RESULT} gidchanged"
else
TEST_RESULT="${TEST_RESULT} norkhgid"
fi
fi
#
# Check the file inode number.
#
if [ $PRELINKED -eq 0 ]; then
RKH_CC2=`expr $RKH_CC + 1`
RKHINODE=`echo ${RKHLINE} | cut -d: -f$RKH_CC2`
SYSINODE=`echo ${FDATA} | cut -d: -f1`
if [ -n "${RKHINODE}" ]; then
test "${RKHINODE}" != "${SYSINODE}" && TEST_RESULT="${TEST_RESULT} inodechanged"
else
TEST_RESULT="${TEST_RESULT} norkhinode"
fi
fi
#
# Check the file size.
#
if [ $FILE_IS_PKGD -eq 1 ]; then
if [ -z "`echo \"${PKGMGR_VERIFY_RESULT}\" | egrep 'S|(^\?)'`" ]; then
SIZE_TEST_PASSED=1
else
TEST_RESULT="${TEST_RESULT} verify:sizechanged"
fi
elif [ $PRELINKED -eq 0 -o $FILE_IS_PKGD -eq 0 ]; then
RKH_CC2=`expr $RKH_CC + 5`
RKHSIZE=`echo ${RKHLINE} | cut -d: -f$RKH_CC2`
SYSSIZE=`echo ${FDATA} | cut -d: -f5`
if [ -n "${RKHSIZE}" ]; then
if [ "${RKHSIZE}" = "${SYSSIZE}" ]; then
SIZE_TEST_PASSED=1
else
TEST_RESULT="${TEST_RESULT} sizechanged"
fi
else
TEST_RESULT="${TEST_RESULT} norkhsize"
fi
fi
#
# Check the file modification date-time.
#
if [ $FILE_IS_PKGD -eq 1 ]; then
echo "${PKGMGR_VERIFY_RESULT}" | egrep 'T|(^.......\?)' >/dev/null && TEST_RESULT="${TEST_RESULT} verify:dtmchanged"
elif [ $PRELINKED -eq 0 -o $FILE_IS_PKGD -eq 0 ]; then
RKH_CC2=`expr $RKH_CC + 6`
RKHDTM=`echo ${RKHLINE} | cut -d: -f$RKH_CC2`
SYSDTM=`echo ${FDATA} | cut -d: -f6`
if [ -n "${RKHDTM}" ]; then
test "${RKHDTM}" != "${SYSDTM}" && TEST_RESULT="${TEST_RESULT} dtmchanged"
else
TEST_RESULT="${TEST_RESULT} norkhdtm"
fi
fi
#
# If the file is a link, then check that the target has not changed.
#
if [ -h "${FNAME}" ]; then
if [ $FILE_IS_PKGD -eq 1 ]; then
if [ -n "`echo \"${PKGMGR_VERIFY_RESULT}\" | egrep 'L|(^....\?)'`" ]; then
if [ $HAVE_READLINK -eq 1 ]; then
# Check the link target to see if it is whitelisted.
if [ -z "${SYSLNK}" ]; then
SYSLNK=`${READLINK_CMD} -f "${FNAME}"`
fi
FNGREP=`echo "${SYSLNK}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -n "`echo \"${EXISTWHITELIST}\" | grep \"^${FNGREP}$\"`" ]; then
if [ $VERBOSE_LOGGING -eq 1 ]; then
test -z "${SYSLNK}" && RKHTMPVAR="Unavailable" || RKHTMPVAR=${SYSLNK}
display --to LOG --type INFO FILE_PROP_LINK_WL "`name2text \"${FNAME}\"`" "`name2text \"${RKHTMPVAR}\"`"
fi
else
TEST_RESULT="${TEST_RESULT} verify:linkchanged"
fi
else
TEST_RESULT="${TEST_RESULT} verify:linkchanged"
fi
fi
else
RKH_CC2=`expr $RKH_CC + 8`
SYSLNK_CC=`echo ${RKHLINE} | cut -d: -f$RKH_CC2`
RKH_CC2=`expr $RKH_CC + 9`
SYSLNK_CC=`expr $RKH_CC2 + $SYSLNK_CC`
RKHLNK=`echo ${RKHLINE} | cut -d: -f${RKH_CC2}-${SYSLNK_CC}`
if [ $HAVE_READLINK -eq 1 -a -z "${SYSLNK}" ]; then
SYSLNK=`${READLINK_CMD} -f "${FNAME}"`
fi
if [ -n "${RKHLNK}" ]; then
if [ "${RKHLNK}" != "${SYSLNK}" ]; then
FNGREP=`echo "${SYSLNK}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -n "`echo \"${EXISTWHITELIST}\" | grep \"^${FNGREP}$\"`" ]; then
if [ $VERBOSE_LOGGING -eq 1 ]; then
test -z "${SYSLNK}" && RKHTMPVAR="Unavailable" || RKHTMPVAR="${SYSLNK}"
display --to LOG --type INFO FILE_PROP_LINK_WL "`name2text \"${FNAME}\"`" "`name2text \"${RKHTMPVAR}\"`"
fi
else
TEST_RESULT="${TEST_RESULT} linkchanged"
fi
fi
else
TEST_RESULT="${TEST_RESULT} norkhlnk"
fi
fi
fi
elif [ -z "${WL_FILE}" ]; then
TEST_RESULT="${TEST_RESULT} sysattrunavail"
fi
#
# Check the file permissions here to see if the 'other' permission
# contains a 'w'. The check is against the octal value. Symbolic
# links are ignored.
#
if [ ! -h "${FNAME}" -a $FILE_IS_PKGD -eq 0 ]; then
WL_FILE=""
if [ -n "`echo \"${WRITEWHITELIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
WL_FILE="whitelisted"
WHITELIST_RESULT="${WHITELIST_RESULT} write"
fi
if [ -z "${WL_FILE}" ]; then
SYSPERM=`echo ${FDATA} | cut -d: -f2`
if [ -n "`echo ${SYSPERM} | grep '[2367]\$'`" ]; then
TEST_RESULT="${TEST_RESULT} write"
elif [ -z "${SYSPERM}" ]; then
TEST_RESULT="${TEST_RESULT} syspermunavail"
fi
fi
fi
fi
#
# If we are adding this file to the rkhunter.dat file, then we
# need to remove any failed test results caused by the file
# currently being missing. We then add the file to the list of
# files to be added, and include the detected system attributes
# of the file.
#
if [ $ADDNEWENTRY -eq 1 ]; then
if [ -n "${TEST_RESULT}" ]; then
for RKHTMPVAR in ${TEST_RESULT}; do
case "${RKHTMPVAR}" in
hashchanged|permchanged|uidchanged|gidchanged|inodechanged|sizechanged|dtmchanged|linkchanged)
TEST_RESULT=`echo "${TEST_RESULT}" | sed -e "s/ ${RKHTMPVAR}//"`
;;
esac
done
fi
if [ $FMTVERSION -eq 0 ]; then
NEWRKHENTRIES="${NEWRKHENTRIES}
File:${FNAME}:${SYSHASH}:${SYSINODE}:${SYSPERM}:${SYSUID}:${SYSGID}:${SYSSIZE}:${SYSDTM}::${SYSLNK}:"
else
RKH_CC=`echo "${FNAME}" | tr -c -d ':' | wc -c | tr -d ' '`
SYSLNK_CC=`echo "${SYSLNK}" | tr -c -d ':' | wc -c | tr -d ' '`
NEWRKHENTRIES="${NEWRKHENTRIES}
File:${RKH_CC}:${FNAME}:${SYSHASH}:${SYSINODE}:${SYSPERM}:${SYSUID}:${SYSGID}:${SYSSIZE}:${SYSDTM}::${SYSLNK_CC}:${SYSLNK}:"
fi
fi
fi
#
# We can now carry out the tests which do not
# require the rkhunter.dat file.
#
#
# Do the file immutable-bit check.
#
if [ $SKIP_IMMUT -eq 0 ]; then
#
# Test if the file is whitelisted.
#
WL_FILE=""
RKHTMPVAR=""
if [ -n "`echo \"${IMMUTWHITELIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
WL_FILE="whitelisted"
WHITELIST_RESULT="${WHITELIST_RESULT} immutable"
fi
if [ -z "${WL_FILE}" ]; then
if [ $BSDOS -eq 0 ]; then
if [ ! -h "${FNAME}" ]; then
RKHTMPVAR=`${LSATTR_CMD} "${FNAME}" 2>&1 | cut -d' ' -f1 | grep 'i'`
fi
else
RKHTMPVAR=`ls -lno "${FNAME}" 2>&1 | awk '{ print $5 }' | egrep 'uchg|schg|sappnd|uappnd|sunlnk|sunlink|schange|simmutable|sappend|uappend|uchange|uimmutable'`
fi
#
# Reverse the test result if the immutable bit is always set.
#
if [ $IMMUTABLE_SET -eq 1 ]; then
test -n "${RKHTMPVAR}" && RKHTMPVAR="" || RKHTMPVAR="set"
fi
test -n "${RKHTMPVAR}" && TEST_RESULT="${TEST_RESULT} immutable"
fi
fi
#
# Do the file script replacement check.
#
if [ $SKIP_SCRIPT -eq 0 ]; then
#
# If we are using a package manager, and both the hash test
# and the file size test have passed, then we skip the script
# replacement check. The assumption is that to change a file
# with one value remaining the same is possible, but to change
# it such that both are the same is improbable. It would also
# require the package manager database having being corrupted
# as well.
#
if [ $HASH_TEST_PASSED -eq 0 -o $SIZE_TEST_PASSED -eq 0 ]; then
#
# See if the file is whitelisted.
#
WL_FILE=""
SYSSCRIPT=""
if [ -n "`echo \"${SCRIPTWHITELIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
WL_FILE="whitelisted"
WHITELIST_RESULT="${WHITELIST_RESULT} script"
fi
if [ -z "${WL_FILE}" ]; then
test -n "${BASENAME_CMD}" && RKHTMPVAR=`${BASENAME_CMD} "${FNAME}"` || RKHTMPVAR=`echo "${FNAME}" | sed -e 's:^.*/::'`
if [ "${RKHTMPVAR}" = "rkhunter" ]; then
SYSSCRIPT=`${FILE_CMD} "${FNAME}" 2>&1 | cat -v | egrep -i -v '(shell|/bin/sh) script( |,|$)'`
else
SYSSCRIPT=`${FILE_CMD} "${FNAME}" 2>&1 | cat -v | egrep -i ' script( |,|$)'`
fi
test -n "${SYSSCRIPT}" && TEST_RESULT="${TEST_RESULT} script"
fi
fi
fi
#
# Now output the results.
#
if [ -z "${TEST_RESULT}" ]; then
display --to SCREEN+LOG --type PLAIN --screen-indent 4 --log-indent 2 --result OK --color GREEN NAME "`name2text \"${FNAME}\"`"
else
display --to SCREEN+LOG --type PLAIN --screen-indent 4 --log-indent 2 --result WARNING --color RED NAME "`name2text \"${FNAME}\"`"
PROP_FAILED_COUNT=`expr ${PROP_FAILED_COUNT} + 1`
RKHTMPVAR2=0
RKHTMPVAR3=0
for RKHTMPVAR in ${TEST_RESULT}; do
case "${RKHTMPVAR}" in
hashchanged|permchanged|uidchanged|gidchanged|inodechanged|sizechanged|dtmchanged|linkchanged)
if [ $RKHTMPVAR2 -eq 0 ]; then
RKHTMPVAR2=1
display --to LOG --type WARNING FILE_PROP_CHANGED
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_CHANGED2 "`name2text \"${FNAME}\"`"
fi
case "${RKHTMPVAR}" in
hashchanged)
if [ -z "${SYSHASH}" ]; then
if [ -h "${FNAME}" ]; then
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_SYSHASH_UNAVAIL_BL
else
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_SYSHASH_UNAVAIL
fi
else
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_SYSHASH "${SYSHASH}"
fi
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_RKHHASH "${RKHHASH}"
test $DEPENDENCY_ERR -eq 1 && display --to LOG --type PLAIN --log-indent 9 FILE_PROP_NO_SYSHASH_DEPENDENCY "`name2text \"${FNAME}\"`"
;;
permchanged)
if [ -z "${SYSPERM}" ]; then
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_PERM_UNAVAIL "${RKHPERM}"
else
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_PERM "${SYSPERM}" "${RKHPERM}"
fi
;;
uidchanged)
if [ -z "${SYSUID}" ]; then
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_UID_UNAVAIL "${RKHUID}"
else
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_UID "${SYSUID}" "${RKHUID}"
fi
;;
gidchanged)
if [ -z "${SYSGID}" ]; then
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_GID_UNAVAIL "${RKHGID}"
else
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_GID "${SYSGID}" "${RKHGID}"
fi
;;
inodechanged)
if [ -z "${SYSINODE}" ]; then
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_INODE_UNAVAIL "${RKHINODE}"
else
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_INODE "${SYSINODE}" "${RKHINODE}"
fi
;;
sizechanged)
if [ -z "${SYSSIZE}" ]; then
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_SIZE_UNAVAIL "${RKHSIZE}"
else
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_SIZE "${SYSSIZE}" "${RKHSIZE}"
fi
;;
dtmchanged)
if [ -z "${SYSDTM}" ]; then
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_SYSDTM_UNAVAIL
else
get_readable_date ${SYSDTM}
if [ -n "${READABLE_DATE}" ]; then
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_SYSDTM "${SYSDTM} (${READABLE_DATE})"
else
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_SYSDTM "${SYSDTM}"
fi
fi
get_readable_date ${RKHDTM}
if [ -n "${READABLE_DATE}" ]; then
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_RKHDTM "${RKHDTM} (${READABLE_DATE})"
else
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_RKHDTM "${RKHDTM}"
fi
;;
linkchanged)
test -z "${RKHLNK}" && RKHLNK="Unavailable"
test -z "${SYSLNK}" && SYSLNK="Unavailable"
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_SYSLNK "`name2text \"${FNAME}\"`" "`name2text \"${SYSLNK}\"`"
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_RKHLNK "`name2text \"${FNAME}\"`" "`name2text \"${RKHLNK}\"`"
;;
esac
;;
verify:hashchanged|verify:permchanged|verify:uidchanged|verify:gidchanged|verify:sizechanged|verify:dtmchanged|verify:linkchanged)
if [ $RKHTMPVAR3 -eq 0 ]; then
RKHTMPVAR3=1
display --to LOG --type WARNING FILE_PROP_VRFY
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_CHANGED2 "`name2text \"${FNAME}\"`"
test $DEPENDENCY_ERR -eq 1 && display --to LOG --type PLAIN --log-indent 9 FILE_PROP_NO_SYSHASH_DEPENDENCY "`name2text \"${FNAME}\"`"
fi
case "${RKHTMPVAR}" in
verify:hashchanged)
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_VRFY_HASH
if [ "${RKHHASH}" = "ignore-prelink-dep-err" ]; then
display --to LOG --type INFO --log-indent 9 FILE_PROP_IGNORE_PRELINK_DEP_ERR "`name2text \"${FNAME}\"`"
fi
;;
verify:permchanged)
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_VRFY_PERM
;;
verify:uidchanged)
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_VRFY_UID
;;
verify:gidchanged)
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_VRFY_GID
;;
verify:sizechanged)
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_VRFY_SIZE
;;
verify:dtmchanged)
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_VRFY_DTM
;;
verify:linkchanged)
display --to LOG --type PLAIN --log-indent 9 FILE_PROP_VRFY_LNK
;;
esac
;;
norkhline)
display --to LOG --type WARNING FILE_PROP_NO_RKH_REC "`name2text \"${FNAME}\"`"
;;
norkhhash)
display --to LOG --type WARNING FILE_PROP_NO_RKHHASH "`name2text \"${FNAME}\"`"
;;
norkhperm)
display --to LOG --type WARNING FILE_PROP_NO_RKHPERM "`name2text \"${FNAME}\"`"
;;
norkhuid)
display --to LOG --type WARNING FILE_PROP_NO_RKHUID "`name2text \"${FNAME}\"`"
;;
norkhgid)
display --to LOG --type WARNING FILE_PROP_NO_RKHGID "`name2text \"${FNAME}\"`"
;;
norkhinode)
display --to LOG --type WARNING FILE_PROP_NO_RKHINODE "`name2text \"${FNAME}\"`"
;;
norkhsize)
display --to LOG --type WARNING FILE_PROP_NO_RKHSIZE "`name2text \"${FNAME}\"`"
;;
norkhdtm)
display --to LOG --type WARNING FILE_PROP_NO_RKHDTM "`name2text \"${FNAME}\"`"
;;
norkhlnk)
display --to LOG --type WARNING FILE_PROP_NO_RKHLNK "`name2text \"${FNAME}\"`"
;;
sysattrunavail)
display --to LOG --type WARNING FILE_PROP_NO_SYSATTR "`name2text \"${FNAME}\"`"
;;
write)
display --to LOG --type WARNING FILE_PROP_WRITE "`name2text \"${FNAME}\"`"
;;
syspermunavail)
display --to LOG --type WARNING FILE_PROP_SYSPERM_UNAVAIL "`name2text \"${FNAME}\"`"
;;
immutable)
if [ $IMMUTABLE_SET -eq 0 ]; then
display --to LOG --type WARNING FILE_PROP_IMMUT "`name2text \"${FNAME}\"`"
else
display --to LOG --type WARNING FILE_PROP_IMMUT_NOT_SET "`name2text \"${FNAME}\"`"
fi
;;
script)
test -n "${BASENAME_CMD}" && RKHTMPVAR4=`${BASENAME_CMD} "${FNAME}"` || RKHTMPVAR4=`echo "${FNAME}" | sed -e 's:^.*/::'`
if [ "${RKHTMPVAR4}" = "rkhunter" ]; then
display --to LOG --type WARNING FILE_PROP_SCRIPT_RKH "`name2text \"${FNAME}\"`" "${SYSSCRIPT}"
else
display --to LOG --type WARNING FILE_PROP_SCRIPT "`name2text \"${FNAME}\"`" "${SYSSCRIPT}"
fi
;;
esac
done
fi
if [ -n "${WHITELIST_RESULT}" ]; then
for WL_FILE in ${WHITELIST_RESULT}; do
case "${WL_FILE}" in
hash)
RKHTMPVAR="file hash"
;;
attr)
RKHTMPVAR="file attributes"
;;
write)
RKHTMPVAR="file write permission"
;;
immutable)
RKHTMPVAR="file immutable-bit"
;;
script)
RKHTMPVAR="script replacement"
;;
esac
display --to LOG --type INFO FILE_PROP_WL "`name2text \"${FNAME}\"`" "${RKHTMPVAR}"
done
fi
IFS=$IFSNL
done
IFS=$RKHIFS
#
# We must now loop through the rkhunter.dat file and see if any filenames
# are missing from the rkhunter_prop_list.dat file. If so, then this
# indicates a (probably wildcarded) file has been removed from the system.
#
if [ $USE_DAT_FILE -eq 1 ]; then
IFS=$IFSNL
for RKHTMPVAR in `grep '^File:' "${RKHDAT_FILE}"`; do
if [ $FMTVERSION -eq 0 ]; then
FNAME=`echo "${RKHTMPVAR}" | cut -d: -f2`
else
RKH_CC=`echo "${RKHTMPVAR}" | cut -d: -f2`
RKH_CC2=`expr 3 + $RKH_CC`
FNAME=`echo "${RKHTMPVAR}" | cut -d: -f3-$RKH_CC2`
fi
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -z "`grep \"^${FNAMEGREP}$\" \"${RKH_FILEPROP_LIST}\"`" ]; then
if [ -n "`echo \"${EXISTWHITELIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
#
# Remove the entry from the rkhunter.dat file.
#
if [ $FMTVERSION -eq 0 ]; then
OLDRKHENTRIES="${OLDRKHENTRIES}
File:${FNAME}:.*"
else
OLDRKHENTRIES="${OLDRKHENTRIES}
File:${RKH_CC}:${FNAME}:.*"
fi
elif [ ! -e "${FNAME}" ]; then
PROP_FAILED_COUNT=`expr ${PROP_FAILED_COUNT} + 1`
PROP_FILE_LIST_COUNT=`expr ${PROP_FILE_LIST_COUNT} + 1`
display --to SCREEN+LOG --type PLAIN --screen-indent 4 --log-indent 2 --result WARNING --color RED NAME "`name2text \"${FNAME}\"`"
display --to LOG --type WARNING FILE_PROP_FILE_NOT_EXIST "`name2text \"${FNAME}\"`"
fi
fi
done
IFS=$RKHIFS
fi
#
# Finally, add or remove any specified entries to/from the rkhunter.dat file.
#
test -n "${OLDRKHENTRIES}" -o -n "${NEWRKHENTRIES}" && updt_rkhdat
return
}
suspscan() {
#
# Suspscan content scan using fixed strings.
#
# Suspscan is a CPU hog and only useful to some limit.
# Suspscan should NEVER be enabled by default.
#
# The suspscan options are intially processed in 'get_suspscan_options'.
#
if `check_test suspscan`; then
display --to LOG --type INFO --nl STARTING_TEST suspscan
display --to LOG --type PLAIN --log-indent 2 SUSPSCAN_START
else
display --to LOG --type INFO --nl USER_DISABLED_TEST suspscan
return
fi
#
# First check that we have the commands we need.
#
if [ -z "${FILE_CMD}" ]; then
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --screen-indent 4 SUSPSCAN_CHECK
display --to LOG --type INFO NOT_FOUND_CMD 'file'
return
elif [ -z "${STRINGS_CMD}" ]; then
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --screen-indent 4 SUSPSCAN_CHECK
display --to LOG --type INFO NOT_FOUND_CMD 'strings'
return
fi
#
# Now check that the suspscan data file is usable.
#
if [ ! -e "${DB_PATH}/suspscan.dat" -o ! -s "${DB_PATH}/suspscan.dat" ]; then
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --screen-indent 4 SUSPSCAN_CHECK
display --to LOG --type WARNING --log-indent 9 SUSPSCAN_DAT_MISSING "${DB_PATH}/suspscan.dat"
return
elif [ ! -f "${DB_PATH}/suspscan.dat" -o -h "${DB_PATH}/suspscan.dat" ]; then
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --screen-indent 4 SUSPSCAN_CHECK
display --to LOG --type WARNING --log-indent 9 SUSPSCAN_DAT_NOTAFILE "${DB_PATH}/suspscan.dat"
return
fi
#
# Now log the configurable option values.
#
# Log which directories are to be scanned.
#
if [ $SUSPSCAN_DFLT_DIRS -eq 1 ]; then
display --to LOG --type PLAIN --log-indent 4 SUSPSCAN_NO_DIRS "${SUSPSCAN_DIRS}"
else
display --to LOG --type PLAIN --log-indent 4 SUSPSCAN_DIRS "${SUSPSCAN_DIRS}"
fi
#
# Log the temporary directory being used.
#
if [ $SUSPSCAN_DFLT_TMP -eq 1 ]; then
display --to LOG --type PLAIN --log-indent 4 SUSPSCAN_NO_TEMP "${SUSPSCAN_TEMP}"
else
display --to LOG --type PLAIN --log-indent 4 SUSPSCAN_TEMP "${SUSPSCAN_TEMP}"
fi
#
# Log the maximum file size to handle.
#
if [ $SUSPSCAN_DFLT_MAXSIZE -eq 1 ]; then
display --to LOG --type PLAIN --log-indent 4 SUSPSCAN_NO_SIZE "${SUSPSCAN_MAXSIZE}"
else
display --to LOG --type PLAIN --log-indent 4 SUSPSCAN_SIZE "${SUSPSCAN_MAXSIZE}"
fi
#
# Log the score threshold.
#
if [ $SUSPSCAN_DFLT_THRESH -eq 1 ]; then
display --to LOG --type PLAIN --log-indent 4 SUSPSCAN_NO_THRESH "${SUSPSCAN_THRESH}"
else
display --to LOG --type PLAIN --log-indent 4 SUSPSCAN_THRESH "${SUSPSCAN_THRESH}"
fi
#
# Start the test.
#
FOUND=0
FOUNDDIRS=""
FILENAME="${SUSPSCAN_TEMP}/suspscan.$$.strings"
rm -f ${SUSPSCAN_TEMP}/suspscan.*.strings >/dev/null 2>&1
#
# Set a temporary file to log scan results to.
#
get_temp_file "${RKHTMPDIR}/suspscan.tmp"
SUSPSCAN_TMPFILE="${TEMPFILE}"
touch "${SUSPSCAN_TMPFILE}"
for DIR in ${SUSPSCAN_DIRS}; do
SUSPSCAN_DIR="${DIR}"
if [ -d "${SUSPSCAN_DIR}" ]; then
FOUND=0
if [ $SUSPSCAN_DEBUG -eq 1 ]; then
echo "4 SUSPSCAN_DIR_CHECK "${SUSPSCAN_DIR}"" >>"${SUSPSCAN_TMPFILE}"
fi
$FIND_CMD "${SUSPSCAN_DIR}" -type f -o -type l 2>/dev/null | while read SUSPSCAN_ITEM; do
#
# Skip the debug file which may well be in one of the default suspscan directories.
#
test $DEBUG_OPT -eq 1 -a "${SUSPSCAN_ITEM}" = "${RKHDEBUGFILE}" && continue
#
# If the file is a link, then find what it points to.
#
if [ -h "${SUSPSCAN_ITEM}" ]; then
if [ $HAVE_READLINK -eq 1 ]; then
RKHTMPVAR="${SUSPSCAN_ITEM}"
SUSPSCAN_ITEM=`${READLINK_CMD} -f "${RKHTMPVAR}"`
if [ $SUSPSCAN_DEBUG -eq 1 ]; then
echo "6 SUSPSCAN_FILE_LINK_CHANGE "${RKHTMPVAR}" "${SUSPSCAN_ITEM}"" >>"${SUSPSCAN_TMPFILE}"
fi
else
if [ $SUSPSCAN_DEBUG -eq 1 ]; then
echo "6 SUSPSCAN_FILE_SKIPPED_LINK "${SUSPSCAN_ITEM}"" >>"${SUSPSCAN_TMPFILE}"
fi
continue
fi
fi
#
# Next check the size of the file.
#
if [ ! -s "${SUSPSCAN_ITEM}" ]; then
if [ $SUSPSCAN_DEBUG -eq 1 ]; then
echo "6 SUSPSCAN_FILE_SKIPPED_EMPTY "${SUSPSCAN_ITEM}"" >>"${SUSPSCAN_TMPFILE}"
fi
continue
elif [ -z "`${FIND_CMD} "${SUSPSCAN_ITEM}" -size -${SUSPSCAN_MAXSIZE}c 2>/dev/null`" ]; then
if [ $SUSPSCAN_DEBUG -eq 1 ]; then
echo "6 SUSPSCAN_FILE_SKIPPED_SIZE "${SUSPSCAN_ITEM}"" >>"${SUSPSCAN_TMPFILE}"
fi
continue
fi
#
# Finally, test the file type.
#
FTYPE=`${FILE_CMD} "${SUSPSCAN_ITEM}" 2>&1 | awk -F':' '{ print $NF }' | cut -c2-`
#
# We need to check errors from the file command, but not
# if they are caused by the file disappearing beneath us.
#
test ! -e "${SUSPSCAN_ITEM}" && continue
#
# Adding "text" to the egrep below widens scope at the expense of more false-positives and extending running time.
#
if [ -n "`echo \"${FTYPE}\" | grep -v -i 'compres' | egrep -i 'execu|reloc|shell|libr|data|obj|text'`" ]; then
FOUND=1
SUSPSCAN_NUM=1; SUSPSCAN_SCORE=0; SUSPSCAN_HITCOUNT=0
SUSPSCAN_STRINGS=""
$STRINGS_CMD -n 4 -a "${SUSPSCAN_ITEM}" | head ${HEAD_OPT}$SUSPSCAN_LINETHRESH >"${FILENAME}" 2>&1
for SUSPSCAN_STRING in `grep -v '^Version' "${DB_PATH}/suspscan.dat" | tail ${TAIL_OPT}1` ; do
#
# Break off if the score already exceeds the threshold.
#
if [ $SUSPSCAN_SCORE -ge $SUSPSCAN_THRESH ]; then
break
fi
SUSPSCAN_TERM="${SUSPSCAN_STRING}"
#
# Searchterm with class.
#
case "${SUSPSCAN_STRING}" in
[a-z]:*)
SUSPSCAN_CLASS=`echo "${SUSPSCAN_STRING}" | cut -d: -f1`
SUSPSCAN_TERM=`echo "${SUSPSCAN_STRING}" | cut -d: -f2-`
;;
esac
#
# Searchterm with multiplier.
#
case "${SUSPSCAN_STRING}" in
*+[0-9][0-9]*)
SUSPSCAN_TERM=`echo "${SUSPSCAN_TERM}" | cut -d'+' -f1`
SUSPSCAN_MULTIPLIER=`echo "${SUSPSCAN_STRING}" | cut -d'+' -f2`
;;
esac
grep -i ${SUSPSCAN_TERM} "${FILENAME}" >/dev/null 2>&1
ERRCODE=$?
if [ $ERRCODE -eq 0 ]; then
if [ "$SUSPSCAN_CLASS" = "$SUSPSCAN_CLASS_PREV" ]; then
SUSPSCAN_SCORE=`expr ${SUSPSCAN_SCORE} + 10`
fi
SUSPSCAN_HITS="$SUSPSCAN_NUM ${SUSPSCAN_HITS}"
if [ -n "$SUSPSCAN_MULTIPLIER" ]; then
SUSPSCAN_SCORE=`expr ${SUSPSCAN_SCORE} + ${SUSPSCAN_MULTIPLIER}`
unset SUSPSCAN_MULTIPLIER
else
SUSPSCAN_SCORE=`expr ${SUSPSCAN_SCORE} + 1`
fi
SUSPSCAN_HITCOUNT=`expr $SUSPSCAN_HITCOUNT + 1`
SUSPSCAN_STRINGS="${SUSPSCAN_STRINGS} ${SUSPSCAN_TERM}"
SUSPSCAN_CLASS_PREV="$SUSPSCAN_CLASS"
fi
SUSPSCAN_NUM=`expr ${SUSPSCAN_NUM} + 1`
done
if [ $SUSPSCAN_DEBUG -eq 1 ]; then
echo "6 SUSPSCAN_FILE_CHECK_DEBUG "${SUSPSCAN_ITEM}" "$SUSPSCAN_SCORE" "$SUSPSCAN_HITCOUNT" "${SUSPSCAN_STRINGS}"" >>"${SUSPSCAN_TMPFILE}"
fi
if [ $SUSPSCAN_SCORE -ge $SUSPSCAN_THRESH ]; then
echo "6 SUSPSCAN_FILE_CHECK "${SUSPSCAN_ITEM}" "$SUSPSCAN_SCORE"" >>"${SUSPSCAN_TMPFILE}"
echo "SUSPSCAN_INSPECT "${SUSPSCAN_ITEM}" "$SUSPSCAN_SCORE"" >>"${SUSPSCAN_TMPFILE}"
fi
unset SUSPSCAN_TERM
#
# Compressed or obfuscated.
#
elif [ -n "`echo \"${FTYPE}\" | grep 'corrupted section header size'`" ]; then
if [ $SUSPSCAN_DEBUG -eq 1 ]; then
echo "6 SUSPSCAN_FILE_SKIPPED_TYPE "${SUSPSCAN_ITEM}" "Possible UPX-compressed or Dexter01s obfuscated binary"" >>"${SUSPSCAN_TMPFILE}"
fi
#
# ELF ultimate compression kit (ELFuck).
#
elif [ -n "`echo \"${FTYPE}\" | grep 'invalid class invalid byte order'`" ]; then
if [ $SUSPSCAN_DEBUG -eq 1 ]; then
echo "6 SUSPSCAN_FILE_SKIPPED_TYPE "${SUSPSCAN_ITEM}" "Possible ELFuck obfuscated binary"" >>"${SUSPSCAN_TMPFILE}"
fi
elif [ $SUSPSCAN_DEBUG -eq 1 ]; then
echo "6 SUSPSCAN_FILE_SKIPPED_TYPE "${SUSPSCAN_ITEM}" "${FTYPE}"" >>"${SUSPSCAN_TMPFILE}"
fi
done
else
echo "4 SUSPSCAN_DIR_NOT_EXIST "${SUSPSCAN_DIR}"" >>"${SUSPSCAN_TMPFILE}"
fi
done
rm -f ${SUSPSCAN_TEMP}/suspscan.*.strings >/dev/null 2>&1
#
# Now display the results.
#
cat "${SUSPSCAN_TMPFILE}" | while read LINE; do
LOGCHAR=`echo "$LINE" | cut -c 1`
case "$LOGCHAR" in
4|6) LOGTYPE=`echo "$LINE" | cut -d ' ' -f 2`
case "$LOGTYPE" in
SUSPSCAN_FILE_SKIPPED_TYPE)
SUSP_SKIP_ITEM=`echo "$LINE" | cut -d ' ' -f 3`
SUSP_SKIP_MSG=`echo "$LINE" | cut -d ' ' -f 4-`
if [ $SUSPSCAN_DEBUG -eq 1 ]; then
display --to LOG --type PLAIN --log-indent $LOGCHAR $LOGTYPE "${SUSP_SKIP_ITEM}" "${SUSP_SKIP_MSG}"
fi
;;
*)
display --to LOG --type PLAIN --log-indent $LINE
;;
esac
;;
S)
display --to LOG --type WARNING $LINE
;;
esac
done
FOUNDDIRS=`grep '^6 SUSPSCAN_FILE_CHECK' "${SUSPSCAN_TMPFILE}" | head ${HEAD_OPT}1`
if [ -z "${FOUNDDIRS}" ]; then
display --to SCREEN+LOG --type PLAIN --result NONE_FOUND --color GREEN --screen-indent 4 SUSPSCAN_CHECK
else
# The 'type' here should be PLAIN, but the loop prevents RKH from seeing that a warning has occurred.
display --to SCREEN+LOG --type WARNING --result WARNING --color RED --screen-indent 4 SUSPSCAN_CHECK
fi
rm -f "${SUSPSCAN_TMPFILE}"
return
}
do_system_commands_checks() {
#
# This function carries out a sequence of tests on
# system commands. These consist of the 'strings' command
# check, library checks and the file properties checks.
#
if `check_test system_commands`; then
display --to LOG --type INFO --screen-nl --nl STARTING_TEST system_commands
display --to SCREEN+LOG --type PLAIN --color YELLOW CHECK_SYS_COMMANDS
else
display --to LOG --type INFO --nl USER_DISABLED_TEST system_commands
return
fi
strings_check
shared_libs_check
file_properties_check
keypresspause
return
}
rootkit_file_dir_checks() {
#
# This function performs the check for known rootkit
# files and directories.
#
if `check_test known_rkts`; then
display --to LOG --type INFO --screen-nl --nl STARTING_TEST known_rkts
display --to SCREEN+LOG --type PLAIN --screen-indent 2 ROOTKIT_FILES_DIRS_START
else
display --to LOG --type INFO --nl USER_DISABLED_TEST known_rkts
return
fi
# 55808 Trojan - Variant A
SCAN_ROOTKIT="55808 Trojan - Variant A"
SCAN_FILES=${W55808A_FILES}
SCAN_DIRS=${W55808A_DIRS}
SCAN_KSYMS=${W55808A_KSYMS}
scanrootkit
# ADM Worm
SCAN_ROOTKIT="ADM Worm"
ROOTKIT_COUNT=`expr ${ROOTKIT_COUNT} + 1`
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --nl ROOTKIT_FILES_DIRS_NAME_LOG "${SCAN_ROOTKIT}"
fi
if [ -f "/etc/passwd" ]; then
RKHTMPVAR=`grep 'w0rm' /etc/passwd`
if [ -z "${RKHTMPVAR}" ]; then
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result NOT_FOUND --log-indent 2 ROOTKIT_FILES_DIRS_STR 'w0rm'
fi
display --to SCREEN+LOG --type PLAIN --result NOT_FOUND --color GREEN --screen-indent 4 NAME "${SCAN_ROOTKIT}"
else
ROOTKIT_FAILED_COUNT=`expr ${ROOTKIT_FAILED_COUNT} + 1`
ROOTKIT_FAILED_NAMES="${ROOTKIT_FAILED_NAMES}${SCAN_ROOTKIT}, "
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result FOUND --log-indent 2 ROOTKIT_FILES_DIRS_STR 'w0rm'
fi
display --to SCREEN+LOG --type WARNING --result WARNING --color RED --screen-indent 4 NAME "${SCAN_ROOTKIT}"
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_FILES_DIRS_STR_FOUND 'w0rm' '/etc/passwd'
fi
else
display --to SCREEN+LOG --type WARNING --result WARNING --color RED --screen-indent 4 NAME "${SCAN_ROOTKIT}"
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_FILES_DIRS_NOFILE '/etc/passwd'
fi
# AjaKit Rootkit
SCAN_ROOTKIT="AjaKit Rootkit"
SCAN_FILES=${AJAKIT_FILES}
SCAN_DIRS=${AJAKIT_DIRS}
SCAN_KSYMS=${AJAKIT_KSYMS}
scanrootkit
# "Adore" Rootkit
SCAN_ROOTKIT="Adore Rootkit"
SCAN_FILES=${AKIT_FILES}
SCAN_DIRS=${AKIT_DIRS}
SCAN_KSYMS=${AKIT_KSYMS}
scanrootkit
# aPa Kit
SCAN_ROOTKIT="aPa Kit"
SCAN_FILES=${APAKIT_FILES}
SCAN_DIRS=${APAKIT_DIRS}
SCAN_KSYMS=${APAKIT_KSYMS}
scanrootkit
# Apache worm
SCAN_ROOTKIT="Apache Worm"
SCAN_FILES=${APACHEWORM_FILES}
SCAN_DIRS=${APACHEWORM_DIRS}
SCAN_KSYMS=${APACHEWORM_KSYMS}
scanrootkit
# Ambient (ark) Rootkit
SCAN_ROOTKIT="Ambient (ark) Rootkit"
SCAN_FILES=${ARK_FILES}
SCAN_DIRS=${ARK_DIRS}
SCAN_KSYMS=${ARK_KSYMS}
scanrootkit
# Balaur Rootkit
SCAN_ROOTKIT="Balaur Rootkit"
SCAN_FILES=${BALAUR_FILES}
SCAN_DIRS=${BALAUR_DIRS}
SCAN_KSYMS=${BALAUR_KSYMS}
scanrootkit
# BeastKit Rootkit
SCAN_ROOTKIT="BeastKit Rootkit"
SCAN_FILES=${BEASTKIT_FILES}
SCAN_DIRS=${BEASTKIT_DIRS}
SCAN_KSYMS=${BEASTKIT_KSYMS}
scanrootkit
# beX2 Rootkit
SCAN_ROOTKIT="beX2 Rootkit"
SCAN_FILES=${BEX_FILES}
SCAN_DIRS=${BEX_DIRS}
SCAN_KSYMS=${BEX_KSYMS}
scanrootkit
# BOBKit Rootkit
SCAN_ROOTKIT="BOBKit Rootkit"
SCAN_FILES=${BOBKIT_FILES}
SCAN_DIRS=${BOBKIT_DIRS}
SCAN_KSYMS=${BOBKIT_KSYMS}
scanrootkit
# OSX Boonana Trojan
if [ $MACOSX -eq 1 ]; then
SCAN_ROOTKIT="Boonana Trojan"
SCAN_FILES=${BOONANA_FILES}
SCAN_DIRS=${BOONANA_DIRS}
SCAN_KSYMS=${BOONANA_KSYMS}
scanrootkit
fi
# cb Rootkit
SCAN_ROOTKIT="cb Rootkit"
SCAN_FILES=${CB_FILES}
SCAN_DIRS=${CB_DIRS}
SCAN_KSYMS=${CB_KSYMS}
scanrootkit
# CiNIK Worm (Slapper.B variant)
SCAN_ROOTKIT="CiNIK Worm (Slapper.B variant)"
SCAN_FILES=${CINIK_FILES}
SCAN_DIRS=${CINIK_DIRS}
SCAN_KSYMS=${CINIK_KSYMS}
scanrootkit
# CX Rootkit
if [ $SUNOS -eq 1 ]; then
SCAN_ROOTKIT="CX Rootkit"
SCAN_FILES=${CXKIT_FILES}
SCAN_DIRS=${CXKIT_DIRS}
SCAN_KSYMS=${CXKIT_KSYMS}
scanrootkit
fi
# Danny-Boy's Abuse Kit
SCAN_ROOTKIT="Danny-Boy's Abuse Kit"
SCAN_FILES=${DANNYBOYS_FILES}
SCAN_DIRS=${DANNYBOYS_DIRS}
SCAN_KSYMS=${DANNYBOYS_KSYMS}
scanrootkit
# Devil RootKit
SCAN_ROOTKIT="Devil RootKit"
SCAN_FILES=${DEVIL_FILES}
SCAN_DIRS=${DEVIL_DIRS}
SCAN_KSYMS=${DEVIL_KSYMS}
scanrootkit
# Dica-Kit Rootkit
SCAN_ROOTKIT="Dica-Kit Rootkit"
SCAN_FILES=${DICA_FILES}
SCAN_DIRS=${DICA_DIRS}
SCAN_KSYMS=${DICA_KSYMS}
scanrootkit
# Dreams RootKit
SCAN_ROOTKIT="Dreams Rootkit"
SCAN_FILES=${DREAMS_FILES}
SCAN_DIRS=${DREAMS_DIRS}
SCAN_KSYMS=${DREAMS_KSYMS}
scanrootkit
# Duarawkz Rootkit
SCAN_ROOTKIT="Duarawkz Rootkit"
SCAN_FILES=${DUARAWKZ_FILES}
SCAN_DIRS=${DUARAWKZ_DIRS}
SCAN_KSYMS=${DUARAWKZ_KSYMS}
scanrootkit
# Enye LKM
SCAN_ROOTKIT="Enye LKM"
SCAN_FILES=${ENYELKM_FILES}
SCAN_DIRS=${ENYELKM_DIRS}
SCAN_KSYMS=${ENYELKM_KSYMS}
scanrootkit
# Flea Linux Rootkit
SCAN_ROOTKIT="Flea Linux Rootkit"
SCAN_FILES=${FLEA_FILES}
SCAN_DIRS=${FLEA_DIRS}
SCAN_KSYMS=${FLEA_KSYMS}
scanrootkit
# FreeBSD Rootkit
if [ $BSDOS -eq 1 ]; then
SCAN_ROOTKIT="FreeBSD Rootkit"
SCAN_FILES=${FREEBSD_RK_FILES}
SCAN_DIRS=${FREEBSD_RK_DIRS}
SCAN_KSYMS=${FREEBSD_RK_KSYMS}
scanrootkit
fi
# Fu Rootkit
SCAN_ROOTKIT="Fu Rootkit"
SCAN_FILES=${FU_FILES}
SCAN_DIRS=${FU_DIRS}
SCAN_KSYMS=${FU_KSYMS}
scanrootkit
# Fuck`it Rootkit
SCAN_ROOTKIT="Fuck\`it Rootkit"
SCAN_FILES=${FUCKIT_FILES}
SCAN_DIRS=${FUCKIT_DIRS}
SCAN_KSYMS=${FUCKIT_KSYMS}
scanrootkit
# GasKit Rootkit
SCAN_ROOTKIT="GasKit Rootkit"
SCAN_FILES=${GASKIT_FILES}
SCAN_DIRS=${GASKIT_DIRS}
SCAN_KSYMS=${GASKIT_KSYMS}
scanrootkit
# Heroin LKM
SCAN_ROOTKIT="Heroin LKM"
SCAN_FILES=${HEROIN_FILES}
SCAN_DIRS=${HEROIN_DIRS}
SCAN_KSYMS=${HEROIN_KSYMS}
scanrootkit
# HjC Kit
SCAN_ROOTKIT="HjC Kit"
SCAN_FILES=${HJCKIT_FILES}
SCAN_DIRS=${HJCKIT_DIRS}
SCAN_KSYMS=${HJCKIT_KSYMS}
scanrootkit
# ignoKit Rootkit
SCAN_ROOTKIT="ignoKit Rootkit"
SCAN_FILES=${IGNOKIT_FILES}
SCAN_DIRS=${IGNOKIT_DIRS}
SCAN_KSYMS=${IGNOKIT_KSYMS}
scanrootkit
# iLLogiC Rootkit (SunOS Rootkit variant)
if [ $SUNOS -eq 1 ]; then
SCAN_ROOTKIT="iLLogiC Rootkit"
SCAN_FILES=${ILLOGIC_FILES}
SCAN_DIRS=${ILLOGIC_DIRS}
SCAN_KSYMS=${ILLOGIC_KSYMS}
scanrootkit
fi
# OSX Inqtana (Variant A)
if [ $MACOSX -eq 1 ]; then
SCAN_ROOTKIT="Inqtana Worm (Variant A)"
SCAN_FILES=${INQTANAA_FILES}
SCAN_DIRS=${INQTANAA_DIRS}
SCAN_KSYMS=${INQTANAA_KSYMS}
scanrootkit
fi
# OSX Inqtana (Variant B)
if [ $MACOSX -eq 1 ]; then
SCAN_ROOTKIT="Inqtana Worm (Variant B)"
SCAN_FILES=${INQTANAB_FILES}
SCAN_DIRS=${INQTANAB_DIRS}
SCAN_KSYMS=${INQTANAB_KSYMS}
scanrootkit
fi
# OSX Inqtana (Variant C)
if [ $MACOSX -eq 1 ]; then
SCAN_ROOTKIT="Inqtana Worm (Variant C)"
SCAN_FILES=${INQTANAC_FILES}
SCAN_DIRS=${INQTANAC_DIRS}
SCAN_KSYMS=${INQTANAC_KSYMS}
scanrootkit
fi
# IntoXonia-NG Rootkit
SCAN_ROOTKIT="IntoXonia-NG Rootkit"
SCAN_FILES=${INTOXONIA_FILES}
SCAN_DIRS=${INTOXONIA_DIRS}
SCAN_KSYMS=${INTOXONIA_KSYMS}
scanrootkit
# Irix Rootkit
SCAN_ROOTKIT="Irix Rootkit"
SCAN_FILES=${IRIXRK_FILES}
SCAN_DIRS=${IRIXRK_DIRS}
SCAN_KSYMS=${IRIXRK_KSYMS}
scanrootkit
# Jynx Rootkit
SCAN_ROOTKIT="Jynx Rootkit"
SCAN_FILES=${JYNX_FILES}
SCAN_DIRS=${JYNX_DIRS}
SCAN_KSYMS=${JYNX_KSYMS}
scanrootkit
# KBeast Rootkit
SCAN_ROOTKIT="KBeast Rootkit"
SCAN_FILES=${KBEAST_FILES}
SCAN_DIRS=${KBEAST_DIRS}
SCAN_KSYMS=${KBEAST_KSYMS}
scanrootkit
# Kitko Rootkit
SCAN_ROOTKIT="Kitko Rootkit"
SCAN_FILES=${KITKO_FILES}
SCAN_DIRS=${KITKO_DIRS}
SCAN_KSYMS=${KITKO_KSYMS}
scanrootkit
# Knark Rootkit
SCAN_ROOTKIT="Knark Rootkit"
SCAN_FILES=${KNARK_FILES}
SCAN_DIRS=${KNARK_DIRS}
SCAN_KSYMS=${KNARK_KSYMS}
scanrootkit
# ld-linuxv.so (LD_PRELOAD shared library rootkit)
SCAN_ROOTKIT="ld-linuxv.so Rootkit"
SCAN_FILES=${LINUXV_FILES}
SCAN_DIRS=${LINUXV_DIRS}
SCAN_KSYMS=${LINUXV_KSYMS}
scanrootkit
# Li0n Worm
SCAN_ROOTKIT="Li0n Worm"
SCAN_FILES=${LION_FILES}
SCAN_DIRS=${LION_DIRS}
SCAN_KSYMS=${LION_KSYMS}
scanrootkit
# Lockit / LJK2 Rootkit
SCAN_ROOTKIT="Lockit / LJK2 Rootkit"
SCAN_FILES=${LOCKIT_FILES}
SCAN_DIRS=${LOCKIT_DIRS}
SCAN_KSYMS=${LOCKIT_KSYMS}
scanrootkit
# Mood-NT Rootkit
SCAN_ROOTKIT="Mood-NT Rootkit"
SCAN_FILES=${MOODNT_FILES}
SCAN_DIRS=${MOODNT_DIRS}
SCAN_KSYMS=${MOODNT_KSYMS}
scanrootkit
# MRK (MiCrobul?) RootKit
SCAN_ROOTKIT="MRK Rootkit"
SCAN_FILES=${MRK_FILES}
SCAN_DIRS=${MRK_DIRS}
SCAN_KSYMS=${MRK_KSYMS}
scanrootkit
# Ni0 Rootkit
SCAN_ROOTKIT="Ni0 Rootkit"
SCAN_FILES=${NIO_FILES}
SCAN_DIRS=${NIO_DIRS}
SCAN_KSYMS=${NIO_KSYMS}
scanrootkit
# Ohhara Rootkit
SCAN_ROOTKIT="Ohhara Rootkit"
SCAN_FILES=${OHHARA_FILES}
SCAN_DIRS=${OHHARA_DIRS}
SCAN_KSYMS=${OHHARA_KSYMS}
scanrootkit
# Optic Kit Worm
SCAN_ROOTKIT="Optic Kit (Tux) Worm"
SCAN_FILES=${OPTICKIT_FILES}
SCAN_DIRS=${OPTICKIT_DIRS}
SCAN_KSYMS=${OPTICKIT_KSYMS}
scanrootkit
# OSX Rootkit 0.2.1
if [ $MACOSX -eq 1 ]; then
SCAN_ROOTKIT="OS X Rootkit"
SCAN_FILES="${OSXRK_FILES}"
SCAN_DIRS="${OSXRK_DIRS}"
SCAN_KSYMS=${OSXRK_KSYMS}
scanrootkit
fi
# Oz Rootkit
SCAN_ROOTKIT="Oz Rootkit"
SCAN_FILES=${OZ_FILES}
SCAN_DIRS=${OZ_DIRS}
SCAN_KSYMS=${OZ_KSYMS}
scanrootkit
# Phalanx Rootkit
SCAN_ROOTKIT="Phalanx Rootkit"
SCAN_FILES=${PHALANX_FILES}
SCAN_DIRS=${PHALANX_DIRS}
SCAN_KSYMS=${PHALANX_KSYMS}
scanrootkit
# Phalanx2 Rootkit (dirs and files)
SCAN_ROOTKIT="Phalanx2 Rootkit"
SCAN_FILES=${PHALANX2_FILES}
SCAN_DIRS=${PHALANX2_DIRS}
SCAN_KSYMS=${PHALANX2_KSYMS}
scanrootkit
# Phalanx2 Rootkit (extended tests)
if [ $LINUXOS -eq 1 ]; then
SCAN_ROOTKIT="Phalanx2 Rootkit (extended tests)"
ROOTKIT_COUNT=`expr ${ROOTKIT_COUNT} + 1`
ROOTKIT_PHALANX2_TEST=0
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --nl ROOTKIT_FILES_DIRS_NAME_LOG "${SCAN_ROOTKIT}"
fi
if [ $ROOTKIT_PHALANX2_DIRTESTVAL -eq 1 ]; then
ROOTKIT_PHALANX2_DIRNAMES=`${FIND_CMD} /etc /usr -type d -iname "*.p2"`
else
ROOTKIT_PHALANX2_DIRNAMES="/etc/khubd.p2 /etc/lolzz.p2 /usr/lib/zupzz.p2"
fi
if [ -n "${ROOTKIT_PHALANX2_DIRNAMES}" ]; then
for ROOTKIT_PHALANX2_DIRNAME in ${ROOTKIT_PHALANX2_DIRNAMES}; do
if `cd ${ROOTKIT_PHALANX2_DIRNAME} >/dev/null 2>&1`; then
ROOTKIT_PHALANX2_TEST=1
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result FOUND --log-indent 2 ROOTKIT_FILES_DIRS_DIR "${ROOTKIT_PHALANX2_DIRNAME}"
fi
display --to SCREEN+LOG --type WARNING --result WARNING --color RED --screen-indent 4 NAME "${SCAN_ROOTKIT}"
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_FILES_DIRS_DIR_FOUND "${ROOTKIT_PHALANX2_DIRNAME}"
elif [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result NOT_FOUND --log-indent 2 ROOTKIT_FILES_DIRS_DIR "${ROOTKIT_PHALANX2_DIRNAME}"
fi
done
elif [ $VERBOSE_LOGGING -eq 1 -a $ROOTKIT_PHALANX2_DIRTESTVAL -eq 1 ]; then
display --to LOG --type PLAIN --result NOT_FOUND --log-indent 2 ROOTKIT_FILES_DIRS_DIR "*.p2"
fi
if `grep -q '^/dev/root .* ext[23] ' /proc/mounts 2>/dev/null`; then
if [ -n "${STAT_CMD}" ]; then
for DIR_NAME in /etc /usr/share; do
if [ -n "`echo \"${STAT_CMD}\" | grep '\.pl$'`" ]; then
NLINKS1=`${STAT_CMD} --nlink ${DIR_NAME} 2>/dev/null`
else
NLINKS1=`${STAT_CMD} -c %h ${DIR_NAME} 2>/dev/null`
fi
NLINKS2=`ls -ld ${DIR_NAME} 2>/dev/null | awk -F' ' '/^d/ {print $2}' | head ${HEAD_OPT}1`
test -z "${NLINKS1}" && NLINKS1=-1
test -z "${NLINKS2}" && NLINKS2=-2
if [ $NLINKS1 -ne $NLINKS2 ]; then
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result WARNING --log-indent 2 ROOTKIT_LINK_COUNT "${DIR_NAME}"
if [ $NLINKS1 -eq -1 ]; then
display --to LOG --type PLAIN --log-indent 4 ROOTKIT_LINK_COUNT_CMDERR "${STAT_CMD}" "${DIR_NAME}"
fi
if [ $NLINKS2 -eq -2 ]; then
display --to LOG --type PLAIN --log-indent 4 ROOTKIT_LINK_COUNT_CMDERR 'ls -ld' "${DIR_NAME}"
fi
display --to LOG --type PLAIN --log-indent 4 ROOTKIT_LINK_COUNT_FAIL "${STAT_CMD}" "$NLINKS1"
display --to LOG --type PLAIN --log-indent 4 ROOTKIT_LINK_COUNT_FAIL 'ls -ld' "$NLINKS2"
fi
if [ $ROOTKIT_PHALANX2_TEST -eq 0 ]; then
ROOTKIT_PHALANX2_TEST=1
display --to SCREEN+LOG --type WARNING --result WARNING --color RED --screen-indent 4 NAME "${SCAN_ROOTKIT}"
fi
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_PHALANX2_LINK_COUNT_FAIL "${DIR_NAME}"
elif [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result OK --log-indent 2 ROOTKIT_LINK_COUNT "${DIR_NAME}"
fi
done
elif [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result SKIPPED --log-indent 2 ROOTKIT_LINK_COUNT '/etc and /usr/share'
display --to LOG --type INFO NOT_FOUND_CMD 'stat'
fi
fi
# On Linux 2.6 kernels certain processes are children of the kthread process which itself is a child of init.
# argv[0] hiding in plain sight works OK (who expects '^ata/0$' processes to be illegal?) but if the parent process Id is not kthread's
# then suspicion is justified. Like other process listing relying on 'ps' the usual process hiding caveat remains.
if [ -n "${PGREP_CMD}" ]; then
if [ -n "`${PGREP_CMD} 'ata/0'`" ]; then
ROOTKIT_PHALANX2_PROC_KTHREAD_PPID=`${PGREP_CMD} -f '^kthread.?$'`
ROOTKIT_PHALANX2_PROC_ATA_PPID=`${PS_CMD} --no-headers -C 'ata/0' -oppid 2>/dev/null`
if [ -n "${ROOTKIT_PHALANX2_PROC_ATA_PPID}" -a -n "${ROOTKIT_PHALANX2_PROC_KTHREAD_PPID}" ]; then
if [ ${ROOTKIT_PHALANX2_PROC_ATA_PPID} -ne ${ROOTKIT_PHALANX2_PROC_KTHREAD_PPID} ]; then
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result WARNING --log-indent 2 ROOTKIT_PHALANX2_PROC_FOUND
display --to LOG --type PLAIN --log-indent 4 ROOTKIT_PHALANX2_PROC_PPID "${ROOTKIT_PHALANX2_PROC_KTHREAD_PPID}" "${ROOTKIT_PHALANX2_PROC_ATA_PPID}"
fi
if [ $ROOTKIT_PHALANX2_TEST -eq 0 ]; then
ROOTKIT_PHALANX2_TEST=1
display --to SCREEN+LOG --type WARNING --result WARNING --color RED --screen-indent 4 NAME "${SCAN_ROOTKIT}"
fi
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_PHALANX2_PROC_FOUND
else
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result OK --log-indent 2 ROOTKIT_PHALANX2_PROC
fi
fi
else # ROOTKIT_PHALANX2_PROC_ATA_PPID ps might not support some cmdline args
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result SKIPPED --log-indent 2 ROOTKIT_PHALANX2_PROC
display --to LOG --type INFO ROOTKIT_PHALANX2_PROC_PS_ERR
fi
fi
#else # This kernel does not run any 'ata/0' kthread child processes, no warning necessary.
fi
else # PGREP_CMD not found
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result SKIPPED --log-indent 2 ROOTKIT_PHALANX2_PROC
display --to LOG --type INFO NOT_FOUND_CMD 'pgrep'
fi
fi
if [ $ROOTKIT_PHALANX2_TEST -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --result NOT_FOUND --color GREEN --screen-indent 4 NAME "${SCAN_ROOTKIT}"
else
ROOTKIT_FAILED_COUNT=`expr ${ROOTKIT_FAILED_COUNT} + 1`
ROOTKIT_FAILED_NAMES="${ROOTKIT_FAILED_NAMES}${SCAN_ROOTKIT}, "
fi
fi
# Portacelo Rootkit
SCAN_ROOTKIT="Portacelo Rootkit"
SCAN_FILES=${PORTACELO_FILES}
SCAN_DIRS=${PORTACELO_DIRS}
SCAN_KSYMS=${PORTACELO_KSYMS}
scanrootkit
# R3dstorm Toolkit
SCAN_ROOTKIT="R3dstorm Toolkit"
SCAN_FILES=${REDSTORM_FILES}
SCAN_DIRS=${REDSTORM_DIRS}
SCAN_KSYMS=${REDSTORM_KSYMS}
scanrootkit
# RH-Sharpe's Rootkit
SCAN_ROOTKIT="RH-Sharpe's Rootkit"
SCAN_FILES=${RHSHARPES_FILES}
SCAN_DIRS=${RHSHARPES_DIRS}
SCAN_KSYMS=${RHSHARPES_KSYMS}
scanrootkit
# RSHA's Rootkit
SCAN_ROOTKIT="RSHA's Rootkit"
SCAN_FILES=${RSHA_FILES}
SCAN_DIRS=${RSHA_DIRS}
SCAN_KSYMS=${RSHA_KSYMS}
scanrootkit
# Scalper Worm
SCAN_ROOTKIT="Scalper Worm"
SCAN_FILES=${SCALPER_FILES}
SCAN_DIRS=${SCALPER_DIRS}
SCAN_KSYMS=${SCALPER_KSYMS}
scanrootkit
# Sebek LKM (Honeypot)
SCAN_ROOTKIT="Sebek LKM"
ROOTKIT_COUNT=`expr ${ROOTKIT_COUNT} + 1`
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --nl ROOTKIT_FILES_DIRS_NAME_LOG "${SCAN_ROOTKIT}"
fi
FOUND=0
if [ -n "${KSYMS_FILE}" ]; then
egrep -i 'adore|sebek' "${KSYMS_FILE}" >/dev/null 2>&1 && FOUND=1
fi
if [ $FOUND -eq 0 ]; then
if [ $VERBOSE_LOGGING -eq 1 ]; then
if [ -n "${KSYMS_FILE}" ]; then
display --to LOG --type PLAIN --result NOT_FOUND --log-indent 2 ROOTKIT_FILES_DIRS_KSYM 'adore or sebek'
else
display --to LOG --type PLAIN --result SKIPPED --log-indent 2 ROOTKIT_FILES_DIRS_KSYM 'adore or sebek'
fi
fi
display --to SCREEN+LOG --type PLAIN --result NOT_FOUND --color GREEN --screen-indent 4 NAME "${SCAN_ROOTKIT}"
else
ROOTKIT_FAILED_COUNT=`expr ${ROOTKIT_FAILED_COUNT} + 1`
ROOTKIT_FAILED_NAMES="${ROOTKIT_FAILED_NAMES}${SCAN_ROOTKIT}, "
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result FOUND --log-indent 2 ROOTKIT_FILES_DIRS_KSYM 'adore or sebek'
fi
display --to SCREEN+LOG --type WARNING --result WARNING --color RED --screen-indent 4 NAME "${SCAN_ROOTKIT}"
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_FILES_DIRS_KSYM_FOUND 'adore or sebek'
fi
# Shutdown Rootkit
SCAN_ROOTKIT="Shutdown Rootkit"
SCAN_FILES=${SHUTDOWN_FILES}
SCAN_DIRS=${SHUTDOWN_DIRS}
SCAN_KSYMS=${SHUTDOWN_KSYMS}
scanrootkit
# SHV4 Rootkit
SCAN_ROOTKIT="SHV4 Rootkit"
SCAN_FILES=${SHV4_FILES}
SCAN_DIRS=${SHV4_DIRS}
SCAN_KSYMS=${SHV4_KSYMS}
scanrootkit
# SHV5 Rootkit
SCAN_ROOTKIT="SHV5 Rootkit"
SCAN_FILES=${SHV5_FILES}
SCAN_DIRS=${SHV5_DIRS}
SCAN_KSYMS=${SHV5_KSYMS}
scanrootkit
# Sin Rootkit
SCAN_ROOTKIT="Sin Rootkit"
SCAN_FILES=${SINROOTKIT_FILES}
SCAN_DIRS=${SINROOTKIT_DIRS}
SCAN_KSYMS=${SINROOTKIT_KSYMS}
scanrootkit
# SInAR Rootkit
if [ $SUNOS -eq 1 ]; then
FOUND=0
SINARFILES=""
SCAN_ROOTKIT="SInAR Rootkit"
ROOTKIT_COUNT=`expr ${ROOTKIT_COUNT} + 1`
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --nl ROOTKIT_FILES_DIRS_NAME_LOG "${SCAN_ROOTKIT}"
fi
if [ -n "${FIND_CMD}" ]; then
for DIR in ${BINPATHS}; do
FOUNDINDIR="NOT_FOUND"
for FNAME in `${FIND_CMD} "${DIR}" -type f -name "*[sS][iI][nN][aA][rR]*" 2>/dev/null`; do
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -n "`echo \"${RTKT_FILE_WHITELIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
display --to LOG --type INFO FILE_PROP_WL "${FNAME}" known_rkts
elif `grep -i 'sinar' "${FNAME}" >/dev/null 2>&1`; then
FOUND=1
FOUNDINDIR="FOUND"
SINARFILES="${SINARFILES} ${FNAME}"
fi
done
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result "${FOUNDINDIR}" --log-indent 2 ROOTKIT_FILES_DIRS_SINAR_DIR "${DIR}"
fi
done
#
# Now display the result.
#
if [ $FOUND -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --result NOT_FOUND --color GREEN --screen-indent 4 NAME "${SCAN_ROOTKIT}"
else
ROOTKIT_FAILED_COUNT=`expr ${ROOTKIT_FAILED_COUNT} + 1`
ROOTKIT_FAILED_NAMES="${ROOTKIT_FAILED_NAMES}${SCAN_ROOTKIT}, "
display --to SCREEN+LOG --type WARNING --result WARNING --color RED --screen-indent 4 NAME "${SCAN_ROOTKIT}"
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_FILES_DIRS_SINAR "${SINARFILES}"
fi
else
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --screen-indent 4 NAME "${SCAN_ROOTKIT}"
display --to LOG --type INFO NOT_FOUND_CMD 'find'
fi
fi
# Slapper Worm
SCAN_ROOTKIT="Slapper Worm"
SCAN_FILES=${SLAPPER_FILES}
SCAN_DIRS=${SLAPPER_DIRS}
SCAN_KSYMS=${SLAPPER_KSYMS}
scanrootkit
# Sneakin Rootkit
SCAN_ROOTKIT="Sneakin Rootkit"
SCAN_FILES=${SNEAKIN_FILES}
SCAN_DIRS=${SNEAKIN_DIRS}
SCAN_KSYMS=${SNEAKIN_KSYMS}
scanrootkit
# Solaris Wanuk backdoor
if [ $SUNOS -eq 1 ]; then
SCAN_ROOTKIT="Solaris Wanuk backdoor"
SCAN_FILES=${WANUKDOOR_FILES}
SCAN_DIRS=${WANUKDOOR_DIRS}
SCAN_KSYMS=${WANUKDOOR_KSYMS}
scanrootkit
fi
# Solaris Wanuk Worm
if [ $SUNOS -eq 1 ]; then
SCAN_ROOTKIT="Solaris Wanuk Worm"
SCAN_FILES=${WANUKWORM_FILES}
SCAN_DIRS=${WANUKWORM_DIRS}
SCAN_KSYMS=${WANUKWORM_KSYMS}
scanrootkit
fi
# 'Spanish' Rootkit
SCAN_ROOTKIT="'Spanish' Rootkit"
SCAN_FILES=${SPANISH_FILES}
SCAN_DIRS=${SPANISH_DIRS}
SCAN_KSYMS=${SPANISH_KSYMS}
scanrootkit
# Suckit Rootkit
SCAN_ROOTKIT="Suckit Rootkit"
SCAN_FILES=${SUCKIT_FILES}
SCAN_DIRS=${SUCKIT_DIRS}
SCAN_KSYMS=${SUCKIT_KSYMS}
scanrootkit
# SunOS Rootkit
if [ $SUNOS -eq 1 ]; then
SCAN_ROOTKIT="SunOS Rootkit"
SCAN_FILES=${SUNOSROOTKIT_FILES}
SCAN_DIRS=${SUNOSROOTKIT_DIRS}
SCAN_KSYMS=${SUNOSROOTKIT_KSYMS}
scanrootkit
fi
# SunOS / NSDAP Rootkit
if [ $SUNOS -eq 1 ]; then
SCAN_ROOTKIT="SunOS / NSDAP Rootkit"
SCAN_FILES=${NSDAP_FILES}
SCAN_DIRS=${NSDAP_DIRS}
SCAN_KSYMS=${NSDAP_KSYMS}
scanrootkit
fi
# Superkit Rootkit
SCAN_ROOTKIT="Superkit Rootkit"
SCAN_FILES=${SUPERKIT_FILES}
SCAN_DIRS=${SUPERKIT_DIRS}
SCAN_KSYMS=${SUPERKIT_KSYMS}
scanrootkit
# TBD (Telnet BackDoor)
SCAN_ROOTKIT="TBD (Telnet BackDoor)"
SCAN_FILES=${TBD_FILES}
SCAN_DIRS=${TBD_DIRS}
SCAN_KSYMS=${TBD_KSYMS}
scanrootkit
# TeLeKiT Rootkit
SCAN_ROOTKIT="TeLeKiT Rootkit"
SCAN_FILES=${TELEKIT_FILES}
SCAN_DIRS=${TELEKIT_DIRS}
SCAN_KSYMS=${TELEKIT_KSYMS}
scanrootkit
# OSX Togroot Rootkit
if [ $MACOSX -eq 1 ]; then
SCAN_ROOTKIT="Togroot Rootkit"
SCAN_FILES=${TOGROOT_FILES}
SCAN_DIRS=${TOGROOT_DIRS}
SCAN_KSYMS=${TOGROOT_KSYMS}
scanrootkit
fi
# T0rn Rootkit
SCAN_ROOTKIT="T0rn Rootkit"
SCAN_FILES=${TORN_FILES}
SCAN_DIRS=${TORN_DIRS}
SCAN_KSYMS=${TORN_KSYMS}
scanrootkit
# TrNkit Rootkit
SCAN_ROOTKIT="trNkit Rootkit"
SCAN_FILES=${TRNKIT_FILES}
SCAN_DIRS=${TRNKIT_DIRS}
SCAN_KSYMS=${TRNKIT_KSYMS}
scanrootkit
# Trojanit Kit
SCAN_ROOTKIT="Trojanit Kit"
SCAN_FILES=${TROJANIT_FILES}
SCAN_DIRS=${TROJANIT_DIRS}
SCAN_KSYMS=${TROJANIT_KSYMS}
scanrootkit
# Turtle / Turtle2 Rootkit
if [ $BSDOS -eq 1 ]; then
SCAN_ROOTKIT="Turtle Rootkit"
SCAN_FILES=${TURTLE_FILES}
SCAN_DIRS=${TURTLE_DIRS}
SCAN_KSYMS=${TURTLE_KSYMS}
scanrootkit
fi
# Tuxtendo Rootkit
SCAN_ROOTKIT="Tuxtendo Rootkit"
SCAN_FILES=${TUXTENDO_FILES}
SCAN_DIRS=${TUXTENDO_DIRS}
SCAN_KSYMS=${TUXTENDO_KSYMS}
scanrootkit
# Universal Rootkit by K2 (URK)
SCAN_ROOTKIT="URK Rootkit"
SCAN_FILES=${URK_FILES}
SCAN_DIRS=${URK_DIRS}
SCAN_KSYMS=${URK_KSYMS}
scanrootkit
# Vampire Rootkit
SCAN_ROOTKIT="Vampire Rootkit"
SCAN_FILES=${VAMPIRE_FILES}
SCAN_DIRS=${VAMPIRE_DIRS}
SCAN_KSYMS=${VAMPIRE_KSYMS}
scanrootkit
# VcKit Rootkit
SCAN_ROOTKIT="VcKit Rootkit"
SCAN_FILES=${VCKIT_FILES}
SCAN_DIRS=${VCKIT_DIRS}
SCAN_KSYMS=${VCKIT_KSYMS}
scanrootkit
# Volc Rootkit
SCAN_ROOTKIT="Volc Rootkit"
SCAN_FILES=${VOLC_FILES}
SCAN_DIRS=${VOLC_DIRS}
SCAN_KSYMS=${VOLC_KSYMS}
scanrootkit
# weaponX Rootkit
if [ $MACOSX -eq 1 ]; then
SCAN_ROOTKIT="weaponX Rootkit"
SCAN_FILES=${WEAPONX_FILES}
SCAN_DIRS=${WEAPONX_DIRS}
SCAN_KSYMS=${WEAPONX_KSYMS}
scanrootkit
fi
# Xzibit Rootkit
SCAN_ROOTKIT="Xzibit Rootkit"
SCAN_FILES=${XZIBIT_FILES}
SCAN_DIRS=${XZIBIT_DIRS}
SCAN_KSYMS=${XZIBIT_KSYMS}
scanrootkit
# X-Org SunOS Rootkit
if [ $SUNOS -eq 1 ]; then
SCAN_ROOTKIT="X-Org SunOS Rootkit"
SCAN_FILES=${XORGSUNOS_FILES}
SCAN_DIRS=${XORGSUNOS_DIRS}
SCAN_KSYMS=${XORGSUNOS_KSYMS}
scanrootkit
fi
# zaRwT.KiT Rootkit
SCAN_ROOTKIT="zaRwT.KiT Rootkit"
SCAN_FILES=${ZARWT_FILES}
SCAN_DIRS=${ZARWT_DIRS}
SCAN_KSYMS=${ZARWT_KSYMS}
scanrootkit
# ZK Rootkit
SCAN_ROOTKIT="ZK Rootkit"
SCAN_FILES=${ZK_FILES}
SCAN_DIRS=${ZK_DIRS}
SCAN_KSYMS=${ZK_KSYMS}
scanrootkit
return
}
possible_rootkit_file_dir_checks() {
#
# This function performs the check for possible rootkit
# files and directories.
#
if `check_test possible_rkt_files`; then
display --to LOG --type INFO --nl STARTING_TEST possible_rkt_files
display --to LOG --type PLAIN --log-indent 2 ROOTKIT_POSS_FILES_DIRS_LOG
else
display --to LOG --type INFO --nl USER_DISABLED_TEST possible_rkt_files
return
fi
FOUND=0
FOUNDFILES=""
FOUNDDIRS=""
IFS=$IFSNL
for RKHTMPVAR in ${FILESCAN}; do
ROOTKIT_COUNT=`expr ${ROOTKIT_COUNT} + 1`
RKHTMPVAR=`echo ${RKHTMPVAR} | sed -e 's/^[ ]*//'`
TYPE=`echo ${RKHTMPVAR} | cut -d: -f1`
FILE=`echo ${RKHTMPVAR} | cut -d: -f2`
INFO=`echo ${RKHTMPVAR} | cut -d: -f3`
FNAME=`echo "${FILE}" | tr '%' ' '`
case "${TYPE}" in
dir)
if [ -d "${FNAME}" ]; then
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -n "`echo \"${RTKT_DIR_WHITELIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
display --to LOG --type INFO FILE_PROP_WL_DIR "`name2text \"${FNAME}\"`" 'possible_rkt_files'
test $VERBOSE_LOGGING -eq 1 && display --to LOG --type PLAIN --result FOUND --log-indent 4 ROOTKIT_FILES_DIRS_DIR "`name2text \"${FNAME}\"`"
else
FOUND=1
FOUNDDIRS="${FOUNDDIRS}
${FNAME}:${INFO}"
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result WARNING --log-indent 4 ROOTKIT_FILES_DIRS_DIR "`name2text \"${FNAME}\"`"
fi
fi
elif [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result NOT_FOUND --log-indent 4 ROOTKIT_FILES_DIRS_DIR "`name2text \"${FNAME}\"`"
fi
;;
file)
if [ -f "${FNAME}" ]; then
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -n "`echo \"${RTKT_FILE_WHITELIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
display --to LOG --type INFO FILE_PROP_WL "`name2text \"${FNAME}\"`" 'possible_rkt_files'
test $VERBOSE_LOGGING -eq 1 && display --to LOG --type PLAIN --result FOUND --log-indent 4 ROOTKIT_FILES_DIRS_FILE "`name2text \"${FNAME}\"`"
else
FOUND=1
FOUNDFILES="${FOUNDFILES}
${FNAME}:${INFO}"
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result WARNING --log-indent 4 ROOTKIT_FILES_DIRS_FILE "`name2text \"${FNAME}\"`"
fi
fi
elif [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result NOT_FOUND --log-indent 4 ROOTKIT_FILES_DIRS_FILE "`name2text \"${FNAME}\"`"
fi
;;
*)
echo "Error: Unknown file type in possible rootkit check: FILESCAN contains: ${TYPE}"
;;
esac
done
IFS=$RKHIFS
#
# Now display the results.
#
if [ $FOUND -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --result NONE_FOUND --color GREEN --screen-indent 4 --log-indent 2 ROOTKIT_POSS_FILES_DIRS
else
display --to SCREEN+LOG --type WARNING --result WARNING --color RED --screen-indent 4 --log-indent 2 ROOTKIT_POSS_FILES_DIRS
IFS=$IFSNL
FOUNDFILES=`echo "${FOUNDFILES}" | sed -e '/^$/d'`
for RKHTMPVAR in ${FOUNDFILES}; do
FILE=`echo "${RKHTMPVAR}" | cut -d: -f1`
INFO=`echo "${RKHTMPVAR}" | cut -d: -f2`
ROOTKIT_FAILED_COUNT=`expr ${ROOTKIT_FAILED_COUNT} + 1`
ROOTKIT_FAILED_NAMES="${ROOTKIT_FAILED_NAMES}${INFO}, "
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_POSS_FILES_FILE_FOUND "`name2text \"${FILE}\"`" "${INFO}"
done
FOUNDDIRS=`echo "${FOUNDDIRS}" | sed -e '/^$/d'`
for RKHTMPVAR in ${FOUNDDIRS}; do
FILE=`echo "${RKHTMPVAR}" | cut -d: -f1`
INFO=`echo "${RKHTMPVAR}" | cut -d: -f2`
ROOTKIT_FAILED_COUNT=`expr ${ROOTKIT_FAILED_COUNT} + 1`
ROOTKIT_FAILED_NAMES="${ROOTKIT_FAILED_NAMES}${INFO}, "
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_POSS_FILES_DIR_FOUND "`name2text \"${FILE}\"`" "${INFO}"
done
IFS=$RKHIFS
fi
return
}
get_rc_paths() {
#
# This function gets a list of the system startup files.
# Directories are searched for files.
#
# This functions will set the variable RC_PATHS.
#
RC_PATHS=""
RKHTMPVAR2=""
if [ -n "${STARTUP_PATHS}" ]; then
RKHTMPVAR="${STARTUP_PATHS}"
else
RKHTMPVAR="${RCLOCATIONS}"
fi
for DIR in ${RKHTMPVAR}; do
test -h "${DIR}" && continue
if [ -f "${DIR}" ]; then
RC_PATHS="${RC_PATHS}
${DIR}"
RKHTMPVAR2="${RKHTMPVAR2} ${DIR}"
elif [ -d "${DIR}" ]; then
RKHTMPVAR2="${RKHTMPVAR2} ${DIR}"
if [ -n "${FIND_CMD}" ]; then
for FNAME in `${FIND_CMD} "${DIR}" -type f -a ! -type l 2>/dev/null`; do
RC_PATHS="${RC_PATHS}
${FNAME}"
done
else
for FNAME in ${DIR}/*; do
test -f "${FNAME}" -a ! -h "${FNAME}" && RC_PATHS="${RC_PATHS}
${FNAME}"
done
fi
fi
done
if [ $STARTUP_PATHS_LOGGED -eq 0 ]; then
STARTUP_PATHS_LOGGED=1
test -z "${RKHTMPVAR2}" && RKHTMPVAR2="${RKHTMPVAR}"
RKHTMPVAR2=`echo ${RKHTMPVAR2}`
display --to LOG --type INFO CONFIG_STARTUP_PATHS "${RKHTMPVAR2}"
fi
return
}
possible_rootkit_string_checks() {
#
# This function performs the check for possible rootkit
# strings in files.
#
if `check_test possible_rkt_strings`; then
display --to LOG --type INFO --nl STARTING_TEST possible_rkt_strings
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --log-indent 2 ROOTKIT_POSS_STRINGS_LOG
fi
else
display --to LOG --type INFO --nl USER_DISABLED_TEST possible_rkt_strings
return
fi
#
# First check to see that we can run the test.
#
if [ -z "${STRINGS_CMD}" ]; then
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --screen-indent 4 ROOTKIT_POSS_STRINGS
display --to LOG --type INFO NOT_FOUND_CMD 'strings'
return
elif [ "${STARTUP_PATHS}" = "NONE" ]; then
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color GREEN --screen-indent 4 ROOTKIT_POSS_STRINGS
display --to LOG --type INFO STARTUP_NONE_GIVEN
return
fi
#
# Now get and check that the system startup files are okay.
#
get_rc_paths
if [ -z "${RC_PATHS}" ]; then
display --to SCREEN+LOG --type WARNING --result WARNING --color RED --screen-indent 4 ROOTKIT_POSS_STRINGS
display --to LOG --type PLAIN --log-indent 9 STARTUP_CHECK_NO_RC_FILES
return
fi
FOUND=0
FOUNDFILES=""
IFS=$IFSNL
for RKHTMPVAR in ${STRINGSCAN}; do
FOUNDFILE=0
STRINGFOUND=0
FOUNDSTRING=""
RKHTMPVAR=`echo ${RKHTMPVAR} | sed -e 's/^[ ]*//'`
FILE=`echo ${RKHTMPVAR} | cut -d: -f1`
FILESTRING=`echo ${RKHTMPVAR} | cut -d: -f2`
# If the string begins with '+', then it is already a regular expression.
if [ "`echo ${FILESTRING} | cut -c 1`" = "+" ]; then
STRINGGREP=`echo ${FILESTRING} | cut -c 2-`
FILESTRING="${STRINGGREP}"
else
STRINGGREP=`echo ${FILESTRING} | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
fi
INFO=`echo ${RKHTMPVAR} | cut -d: -f3`
if [ "${FILE}" = "rcfile" ]; then
FOUNDFILE=1
for FNAME in ${RC_PATHS}; do
FOUNDSTRING=`${STRINGS_CMD} -n 3 -a "${FNAME}" | grep -v '^[ ]*#' | grep "${STRINGGREP}"`
if [ -n "${FOUNDSTRING}" ]; then
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -n "`echo \"${RTKT_FILE_WHITELIST}\" | grep \"^${FNAMEGREP}:${STRINGGREP}$\"`" ]; then
display --to LOG --type INFO FILE_PROP_WL_STR "`name2text \"${FNAME}\"`" "${FILESTRING}" 'possible_rkt_strings'
elif [ -n "`echo \"${RTKT_FILE_WHITELIST}\" | grep \"^${FNAMEGREP}$\"`" -a -z "`echo \"${RTKT_FILE_WHITELIST}\" | grep \"^${FNAMEGREP}:$\"`" ]; then
display --to LOG --type INFO FILE_PROP_WL "`name2text \"${FNAME}\"`" 'possible_rkt_strings'
else
FOUND=1
STRINGFOUND=1
FOUNDSTRINGS="${FOUNDSTRINGS}
${FNAME}:${FILESTRING}:${INFO}"
fi
fi
done
else
#
# We cannot use the 'find_cmd' function here because we
# are looking at the command binaries themselves, not
# executing them as commands from the local system.
#
# We need to jiggle with IFS here because we are in
# two loops which are using different field separators.
#
IFS=$RKHIFS
for DIR in ${BINPATHS}; do
FNAME="${DIR}/${FILE}"
if [ -f "${FNAME}" ]; then
FOUNDFILE=1
FOUNDSTRING=`${STRINGS_CMD} -n 3 -a "${FNAME}" | grep "${STRINGGREP}"`
if [ -n "${FOUNDSTRING}" ]; then
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -n "`echo \"${RTKT_FILE_WHITELIST}\" | grep \"^${FNAMEGREP}:${STRINGGREP}$\"`" ]; then
display --to LOG --type INFO FILE_PROP_WL_STR "`name2text \"${FNAME}\"`" "${FILESTRING}" 'possible_rkt_strings'
elif [ -n "`echo \"${RTKT_FILE_WHITELIST}\" | grep \"^${FNAMEGREP}$\"`" -a -z "`echo \"${RTKT_FILE_WHITELIST}\" | grep \"^${FNAMEGREP}:$\"`" ]; then
display --to LOG --type INFO FILE_PROP_WL "`name2text \"${FNAME}\"`" 'possible_rkt_strings'
else
FOUND=1
STRINGFOUND=1
FOUNDSTRINGS="${FOUNDSTRINGS}
${FNAME}:${FILESTRING}:${INFO}"
fi
fi
break
fi
done
fi
if [ $FOUNDFILE -eq 1 ]; then
ROOTKIT_COUNT=`expr ${ROOTKIT_COUNT} + 1`
if [ $VERBOSE_LOGGING -eq 1 ]; then
if [ $STRINGFOUND -eq 0 ]; then
display --to LOG --type PLAIN --result NOT_FOUND --log-indent 4 ROOTKIT_FILES_DIRS_STR "${FILESTRING}"
else
display --to LOG --type PLAIN --result WARNING --log-indent 4 ROOTKIT_FILES_DIRS_STR "${FILESTRING}"
fi
fi
fi
IFS=$IFSNL
done
IFS=$RKHIFS
#
# Now display the results.
#
if [ $FOUND -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --result NONE_FOUND --color GREEN --screen-indent 4 --log-indent 2 ROOTKIT_POSS_STRINGS
else
display --to SCREEN+LOG --type WARNING --result WARNING --color RED --screen-indent 4 --log-indent 2 ROOTKIT_POSS_STRINGS
IFS=$IFSNL
FOUNDSTRINGS=`echo "${FOUNDSTRINGS}" | sed -e '/^$/d'`
for RKHTMPVAR in ${FOUNDSTRINGS}; do
FNAME=`echo "${RKHTMPVAR}" | cut -d: -f1`
STRING=`echo "${RKHTMPVAR}" | cut -d: -f2`
if [ "`echo ${STRING} | cut -c 1`" = "+" ]; then
STRING=`echo ${STRING} | cut -c 2-`
fi
INFO=`echo "${RKHTMPVAR}" | cut -d: -f3`
ROOTKIT_FAILED_COUNT=`expr ${ROOTKIT_FAILED_COUNT} + 1`
ROOTKIT_FAILED_NAMES="${ROOTKIT_FAILED_NAMES}${INFO}, "
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_POSS_STRINGS_FOUND "${STRING}" "`name2text \"${FNAME}\"`" "${INFO}"
done
IFS=$RKHIFS
fi
return
}
additional_rootkit_checks() {
#
# This function performs additional rootkit checks.
#
if `check_test additional_rkts`; then
display --to LOG --type INFO --screen-nl --nl STARTING_TEST additional_rkts
display --to SCREEN+LOG --type PLAIN --screen-indent 2 ROOTKIT_ADD_START
else
display --to LOG --type INFO --nl USER_DISABLED_TEST additional_rkts
return
fi
test $LINUXOS -eq 1 && suckit_extra_checks
possible_rootkit_file_dir_checks
possible_rootkit_string_checks
return
}
malware_checks() {
#
# This function performs malware checks.
#
if `check_test malware`; then
display --to LOG --type INFO --screen-nl --nl STARTING_TEST malware
display --to SCREEN+LOG --type PLAIN --screen-indent 2 ROOTKIT_MALWARE_START
else
display --to LOG --type INFO --nl USER_DISABLED_TEST malware
return
fi
#
# First we check for processes using deleted files.
#
if `check_test deleted_files`; then
display --to LOG --type INFO --nl STARTING_TEST deleted_files
if [ -n "${LSOF_CMD}" ]; then
FOUND=0
WHITEPROC=""
BLACKPROC=""
DELE_FILES=`${LSOF_CMD} -wnlP +c 0 ${SOLARISX} | grep '(dele' | head ${HEAD_OPT}1`
if [ -n "${DELE_FILES}" ]; then
PIDLIST=" "
IFS=$IFSNL
for LINE in `${LSOF_CMD} -wnlP +c 0 ${SOLARISX} | grep '(dele'`; do
PROC=""
PID=`echo "${LINE}" | awk '{ print $2 }'`
NODE=`echo "${LINE}" | awk '{ print $8 }'`
FNAME=`echo "${LINE}" | awk '{ print $9 }'`
#
# Skip any PID's we have already seen.
#
test -n "`echo \"${PIDLIST}\" | grep \" $PID \"`" && continue
#
# Try and get the running process name.
#
if [ $HAVE_READLINK -eq 1 ]; then
RKHTMPVAR=""
if [ $SOL_PROC -eq 1 ]; then
test -h "/proc/${PID}/path/a.out" && RKHTMPVAR=`${READLINK_CMD} -f "/proc/${PID}/path/a.out"`
elif [ $SUNOS -eq 0 -o -h "/proc/${PID}/exe" ]; then
test -h "/proc/${PID}/exe" && RKHTMPVAR=`${READLINK_CMD} -f "/proc/${PID}/exe"`
fi
test -n "${RKHTMPVAR}" && PROC=`echo "${RKHTMPVAR}" | cut -d' ' -f1`
fi
if [ -z "${PROC}" ]; then
if [ $SUNOS -eq 1 ]; then
PROC=`${LSOF_CMD} -wnlP +c 0 -p $PID | grep '[ ]txt[ ][ ]*VREG[ ]' | head ${HEAD_OPT}1 | ${AWK_CMD} '{ print $NF }'`
else
PROC=`${LSOF_CMD} -wnlP +c 0 -p $PID | grep '[ ]txt[ ][ ]*REG[ ]' | awk '{ print $NF }'`
fi
test -z "${PROC}" && PROC=`echo "${LINE}" | awk '{ print $1 }'`
fi
#
# If FNAME is not a pathname then look at the NODE.
#
if [ -z "`echo \"${FNAME}\" | grep '^/'`" ]; then
if [ -n "`echo \"${NODE}\" | grep '^/'`" ]; then
FNAME="${NODE}"
fi
fi
#
# Strip anything after the pathname.
#
if [ -n "`echo \"${FNAME}\" | grep '^/'`" ]; then
FNAME=`echo "${FNAME}" | cut -d' ' -f1`
fi
#
# Now see if the process is whitelisted.
#
PROCWHITELISTED=0
PROCDELFILES_GIVEN=0
for RKHTMPVAR in ${ALLOWPROCDELFILES}; do
RKHTMPVAR2=`echo "${RKHTMPVAR}" | awk -F ':/' '{ print $1 }'`
test "${RKHTMPVAR}" = "${RKHTMPVAR2}" && PROCDELFILES_GIVEN=0 || PROCDELFILES_GIVEN=1
if [ "${PROC}" = "${RKHTMPVAR2}" ]; then
if [ $PROCDELFILES_GIVEN -eq 1 ]; then
RKHTMPVAR3=`echo "${RKHTMPVAR}" | awk -F ':/' '{ for (i = 2; i <= NF; i++) { a[i] = $i } } END { for (i in a) { print "/" a[i] } }'`
# Now expand the deleted file pathnames.
RKHTMPVAR3=`expand_paths RKHTMPVAR3`
# We must reset the IFS because 'expand_paths' sets it to the default.
IFS=$IFSNL
FNAMEGREP=`echo "${RKHTMPVAR3}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -n "`echo \"${FNAME}\" | grep \"^${FNAMEGREP}$\"`" ]; then
PROCWHITELISTED=1
fi
else
PROCWHITELISTED=1
fi
test $PROCWHITELISTED -eq 1 && break
fi
done
test $HAVE_READLINK -eq 0 && PROC="\"${PROC}\""
if [ $PROCWHITELISTED -eq 1 ]; then
if [ $PROCDELFILES_GIVEN -eq 1 ]; then
if [ -z "`echo \"${WHITEPROC}\" | grep \"^${PROC} ${FNAME}$\"`" ]; then
WHITEPROC="${WHITEPROC}
${PROC} ${FNAME}"
fi
elif [ -z "`echo \"${WHITEPROC}\" | grep \"^${PROC}$\"`" ]; then
WHITEPROC="${WHITEPROC}
${PROC}"
fi
else
FOUND=1
BLACKPROC="${BLACKPROC}
${PROC} ${PID} ${FNAME}"
fi
#
# Finally add the PID to the seen PID list.
#
PIDLIST="$PIDLIST $PID "
done
fi
#
# Now display the results.
#
if [ $FOUND -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --result NONE_FOUND --color GREEN --log-indent 2 --screen-indent 4 ROOTKIT_MALWARE_DELETED_FILES
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 ROOTKIT_MALWARE_DELETED_FILES
display --to LOG --type WARNING ROOTKIT_MALWARE_DELETED_FILES_FOUND
for LINE in ${BLACKPROC}; do
test -z "${LINE}" && continue
PROC=`echo "$LINE" | cut -d' ' -f1`
PID=`echo "$LINE" | cut -d' ' -f2`
FNAME=`echo "$LINE" | cut -d' ' -f3-`
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_MALWARE_DELETED_FILES_FOUND_DATA "${PROC}" "${PID}" "`name2text \"${FNAME}\"`"
done
fi
for RKHTMPVAR in ${WHITEPROC}; do
test -z "${RKHTMPVAR}" && continue
if [ -n "`echo \"${RKHTMPVAR}\" | grep ' /'`" ]; then
PROC=`echo "${RKHTMPVAR}" | cut -d' ' -f1`
FNAME=`echo "${RKHTMPVAR}" | cut -d' ' -f2-`
display --to LOG --type INFO ROOTKIT_MALWARE_DELETED_FILES_WL "${PROC}" "`name2text \"${FNAME}\"`"
else
display --to LOG --type INFO NETWORK_PACKET_CAP_WL "${RKHTMPVAR}"
fi
done
IFS=$RKHIFS
else
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --log-indent 2 --screen-indent 4 ROOTKIT_MALWARE_DELETED_FILES
display --to LOG --type INFO NOT_FOUND_CMD 'lsof'
fi
else
display --to LOG --type INFO --nl USER_DISABLED_TEST deleted_files
fi
#
# Next we check to see if there any running processes
# using suspicious files.
#
if `check_test running_procs`; then
display --to LOG --type INFO --nl STARTING_TEST running_procs
if [ -n "${LSOF_CMD}" ]; then
#
# First get a temporary file to store the output.
#
get_temp_file "${RKHTMPDIR}/lsofprocs.out"
RKHLSOF_FILE="${TEMPFILE}"
touch "${RKHLSOF_FILE}"
${LSOF_CMD} -wnlP +c 0 2>&1 | egrep -v ' (FIFO|V?DIR|IPv[46]) ' | sort | uniq >"${RKHLSOF_FILE}"
#
# Now loop through the known suspicious filenames,
# and see if any are in the lsof output.
#
FOUND=0
SUSP_FILES=""
IFS=$IFSNL
for RKHTMPVAR in ${SUSP_FILES_INFO}; do
RKHTMPVAR=`echo "${RKHTMPVAR}" | sed -e 's/^[ ]*//'`
FNAME=`echo "${RKHTMPVAR}" | cut -d: -f1`
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
FOUNDFILES=`grep "/${FNAMEGREP}$" "${RKHLSOF_FILE}"`
ROOTKIT_COUNT=`expr $ROOTKIT_COUNT + 1`
if [ -n "${FOUNDFILES}" ]; then
FOUND=0
INFO=`echo "${RKHTMPVAR}" | cut -d: -f2`
#
# It is possible that more than one line of output was found.
# So we must loop through them and record them all.
#
for FNAME in ${FOUNDFILES}; do
#
# See if the filename has been whitelisted.
#
FILENAME=`echo "${FNAME}" | sed -e 's/^.*[ ]\([^ ][^ ]*\)$/\1/'`
FNAMEGREP=`echo "${FILENAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -n "`echo \"${RTKT_FILE_WHITELIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
display --to LOG --type INFO FILE_PROP_WL "`name2text \"${FILENAME}\"`" 'running_procs'
else
FOUND=1
SUSP_FILES="${SUSP_FILES}
${RKHTMPVAR}:${FNAME}"
fi
done
if [ $FOUND -eq 1 ]; then
ROOTKIT_FAILED_COUNT=`expr ${ROOTKIT_FAILED_COUNT} + 1`
ROOTKIT_FAILED_NAMES="${ROOTKIT_FAILED_NAMES}${INFO}, "
fi
fi
done
IFS=$RKHIFS
rm -f "${RKHLSOF_FILE}" >/dev/null 2>&1
if [ $FOUND -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --result NONE_FOUND --color GREEN --log-indent 2 --screen-indent 4 ROOTKIT_MALWARE_SUSP_FILES
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 ROOTKIT_MALWARE_SUSP_FILES
display --to LOG --type WARNING ROOTKIT_MALWARE_SUSP_FILES_FOUND
IFS=$IFSNL
SUSP_FILES=`echo "${SUSP_FILES}" | sed -e '/^$/d'`
for FILENAME in ${SUSP_FILES}; do
INFO=`echo ${FILENAME} | cut -d: -f2`
RKHTMPVAR=`echo ${FILENAME} | cut -d: -f3-`
FOUNDINFO=`echo "${RKHTMPVAR}" | awk '{ print $1 }'`
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_MALWARE_SUSP_FILES_FOUND_CMD "${FOUNDINFO}"
FOUNDINFO=`echo "${RKHTMPVAR}" | awk '{ print $3 }'`
RKHTMPVAR2=`echo "${RKHTMPVAR}" | awk '{ print $2 }'`
display --to LOG --type PLAIN --log-indent 11 ROOTKIT_MALWARE_SUSP_FILES_FOUND_UID "${FOUNDINFO}" "${RKHTMPVAR2}"
FOUNDINFO=`echo "${RKHTMPVAR}" | awk '{ print $9 }'`
display --to LOG --type PLAIN --log-indent 11 ROOTKIT_MALWARE_SUSP_FILES_FOUND_PATH "${FOUNDINFO}"
display --to LOG --type PLAIN --log-indent 11 ROOTKIT_MALWARE_SUSP_FILES_FOUND_RTKT "${INFO}"
done
IFS=$RKHIFS
fi
else
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --log-indent 2 --screen-indent 4 ROOTKIT_MALWARE_SUSP_FILES
display --to LOG --type INFO NOT_FOUND_CMD 'lsof'
fi
else
display --to LOG --type INFO --nl USER_DISABLED_TEST running_procs
fi
#
# Next we check for any hidden processes.
#
if `check_test hidden_procs`; then
FOUND=0
UNHIDE_VERS=0
HIDDEN_PROCS=""
display --to LOG --type INFO --nl STARTING_TEST hidden_procs
#
# First we test for the 'unhide' C program.
#
SEEN=0
RKHTMPVAR="unhide"
UNHIDE_CMD=`find_cmd unhide`
if [ -z "${UNHIDE_CMD}" ]; then
RKHTMPVAR="unhide-posix"
UNHIDE_CMD=`find_cmd unhide-posix`
fi
if [ $LINUXOS -eq 1 -a -z "${UNHIDE_CMD}" ]; then
RKHTMPVAR="unhide-linux"
UNHIDE_CMD=`find_cmd unhide-linux`
if [ -z "${UNHIDE_CMD}" ]; then
if [ -n "`uname -r | grep '^2\.6'`" ]; then
RKHTMPVAR="unhide-linux26"
UNHIDE_CMD=`find_cmd unhide-linux26`
fi
fi
fi
if [ -n "${UNHIDE_CMD}" ]; then
FOUND=1
display --to LOG --type INFO FOUND_CMD "${RKHTMPVAR}" "${UNHIDE_CMD}"
if [ $NOUNHIDE -eq 1 ]; then
SEEN=1
display --to LOG --type INFO ROOTKIT_MALWARE_HIDDEN_PROCS_NOUNHIDE 'unhide'
else
#
# Dig out the version number for use later on.
#
UNHIDE_VERS=`${UNHIDE_CMD} -V 2>/dev/null | head ${HEAD_OPT}1`
if [ -n "`echo ${UNHIDE_VERS} | grep '^Unhide [2-9][0-9]*$'`" ]; then
UNHIDE_VERS=`echo ${UNHIDE_VERS} | cut -d' ' -f2`
else
UNHIDE_VERS=0
fi
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type INFO ROOTKIT_MALWARE_HIDDEN_PROCS_UNHIDE_VERS "${UNHIDE_VERS}"
fi
#
# Now run each of the configured tests.
#
UNHIDE_OPTS=""
FOUND_PROCS=""
for RKHTMPVAR in ${UNHIDE_TESTS}; do
if [ -n "`echo \"${RKHTMPVAR} \" | grep '^-'`" ]; then
# Only newer versions have command-line options.
if [ $UNHIDE_VERS -ge 20100919 ]; then
# Ignore obvious invalid options.
test "${RKHTMPVAR}" = "-V" -o "${RKHTMPVAR}" = "-h" && continue
UNHIDE_OPTS="${UNHIDE_OPTS} ${RKHTMPVAR}"
fi
continue
elif [ $UNHIDE_VERS -lt 20100819 ]; then
# Ignore unknown tests for earlier versions.
test "${RKHTMPVAR}" != "sys" -a "${RKHTMPVAR}" != "proc" -a "${RKHTMPVAR}" != "brute" && continue
fi
SEEN=1
FOUND_PROCS=`${UNHIDE_CMD} ${UNHIDE_OPTS} ${RKHTMPVAR} 2>&1 | egrep -v '^(Unhide |yjesus@|http:|Copyright |License |NOTE :|Used options:|\[\*\]|$)'`
if [ -z "${FOUND_PROCS}" ]; then
# Nothing found.
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result NONE_FOUND --log-indent 4 ROOTKIT_MALWARE_HIDDEN_PROCS_UNHIDE_CMD "${UNHIDE_CMD} ${UNHIDE_OPTS} ${RKHTMPVAR}"
fi
else
# For newer versions we can sort the messages.
if [ $UNHIDE_VERS -ge 20100919 ]; then
FOUND_PROCS=`echo "${FOUND_PROCS}" | sort | uniq`
fi
HIDDEN_PROCS="${HIDDEN_PROCS}
${FOUND_PROCS}"
display --to LOG --type PLAIN --result WARNING --log-indent 4 ROOTKIT_MALWARE_HIDDEN_PROCS_UNHIDE_CMD "${UNHIDE_CMD} ${UNHIDE_OPTS} ${RKHTMPVAR}"
fi
done
#
# Mark the test as skipped if we have not executed any command because of invalid test names.
#
if [ $SEEN -eq 0 ]; then
display --to LOG --type PLAIN --result SKIPPED --log-indent 4 ROOTKIT_MALWARE_HIDDEN_PROCS_UNHIDE_CMD "${UNHIDE_CMD} ${UNHIDE_OPTS} ${RKHTMPVAR}"
fi
fi
else
SEEN=1
display --to LOG --type INFO NOT_FOUND_CMD 'unhide'
if [ "${RKHTMPVAR}" != "unhide" ]; then
display --to LOG --type INFO NOT_FOUND_CMD "${RKHTMPVAR}"
fi
fi
#
# Now display the results.
#
# At this point if SEEN is 0, then a problem occurred with the 'unhide' program.
# We treat these as warnings so that the user is aware that something went
# wrong.
#
HIDDEN_PROCS=`echo "${HIDDEN_PROCS}" | sed -e '/^$/d'`
if [ $FOUND -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --log-indent 2 --screen-indent 4 ROOTKIT_MALWARE_HIDDEN_PROCS
elif [ -z "${HIDDEN_PROCS}" -a $ERRCODE -ne 1 -a $SEEN -eq 1 ]; then
display --to SCREEN+LOG --type PLAIN --result NONE_FOUND --color GREEN --log-indent 2 --screen-indent 4 ROOTKIT_MALWARE_HIDDEN_PROCS
else
#
# At this point we have either found a hidden PID, or an error occurred with the 'unhide' program,
# or both. We need to warn the user in either case. We also need to display all the information.
#
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 ROOTKIT_MALWARE_HIDDEN_PROCS
#
# Lets see if there was a problem executing the 'unhide' commands.
#
if [ $SEEN -eq 0 ]; then
display --to LOG --type WARNING --log-indent 2 ROOTKIT_MALWARE_HIDDEN_PROCS_UNH_ERR "${UNHIDE_TESTS}"
fi
#
# Now display if any actual hidden PIDs were found.
#
if [ -n "${HIDDEN_PROCS}" ]; then
display --to LOG --type WARNING --log-indent 2 ROOTKIT_MALWARE_HIDDEN_PROCS_FOUND
IFS=$IFSNL
for RKHTMPVAR in ${HIDDEN_PROCS}; do
display --to LOG --type PLAIN --log-indent 9 NAME "${RKHTMPVAR}"
done
IFS=$RKHIFS
fi
fi
else
display --to LOG --type INFO --nl USER_DISABLED_TEST hidden_procs
fi
#
# Next we run the check for suspicious file contents.
#
suspscan
#
# We have completed the checks which can be enabled/disabled,
# but we need to be able to exclude or include the rest of the
# malware checks. As such we do a simple test for 'other_malware'
# as a test name, and only proceed if it is enabled.
#
if `check_test other_malware`; then
display --to LOG --type INFO --nl STARTING_TEST other_malware
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --log-indent 2 ROOTKIT_MALWARE_LOGIN_BDOOR_LOG
fi
else
display --to LOG --type INFO --nl USER_DISABLED_TEST other_malware
return
fi
#
# Nex we check for login backdoors.
#
FOUND=0
FOUNDFILES=""
for FNAME in ${LOGIN_BACKDOOR_FILES}; do
if [ -e "${FNAME}" ]; then
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -n "`echo \"${RTKT_FILE_WHITELIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
display --to LOG --type INFO FILE_PROP_WL "`name2text \"${FNAME}\"`" 'other_malware'
else
FOUND=1
FOUNDFILES="${FOUNDFILES} ${FNAME}"
fi
test $VERBOSE_LOGGING -eq 1 && display --to LOG --type PLAIN --result FOUND --log-indent 4 ROOTKIT_MALWARE_LOGIN_BDOOR_CHK "`name2text \"${FNAME}\"`"
elif [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result NOT_FOUND --log-indent 4 ROOTKIT_MALWARE_LOGIN_BDOOR_CHK "`name2text \"${FNAME}\"`"
fi
done
#
# Now display the results.
#
if [ $FOUND -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --result NONE_FOUND --color GREEN --screen-indent 4 --log-indent 2 ROOTKIT_MALWARE_LOGIN_BDOOR
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --screen-indent 4 --log-indent 2 ROOTKIT_MALWARE_LOGIN_BDOOR
for FNAME in ${FOUNDFILES}; do
display --to LOG --type WARNING ROOTKIT_MALWARE_LOGIN_BDOOR_FOUND "`name2text \"${FNAME}\"`"
done
fi
#
# Next check for any suspicious directories.
#
FOUND=0
FOUNDDIRS=""
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --nl --log-indent 2 ROOTKIT_MALWARE_SUSP_DIR_LOG
fi
for DIR in ${SUSPICIOUS_DIRS}; do
if [ -d "${DIR}" ]; then
FNAMEGREP=`echo "${DIR}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -n "`echo \"${RTKT_DIR_WHITELIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
display --to LOG --type INFO FILE_PROP_WL_DIR "`name2text \"${DIR}\"`" 'other_malware'
else
FOUND=1
FOUNDDIRS="${FOUNDDIRS} ${DIR}"
fi
test $VERBOSE_LOGGING -eq 1 && display --to LOG --type PLAIN --result FOUND --log-indent 4 ROOTKIT_FILES_DIRS_DIR "`name2text \"${DIR}\"`"
elif [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result NOT_FOUND --log-indent 4 ROOTKIT_FILES_DIRS_DIR "`name2text \"${DIR}\"`"
fi
done
#
# Now display the results.
#
if [ $FOUND -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --result NONE_FOUND --color GREEN --screen-indent 4 --log-indent 2 ROOTKIT_MALWARE_SUSP_DIR
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --screen-indent 4 --log-indent 2 ROOTKIT_MALWARE_SUSP_DIR
for DIR in ${FOUNDDIRS}; do
display --to LOG --type WARNING ROOTKIT_MALWARE_SUSP_DIR_FOUND "`name2text \"${DIR}\"`"
done
fi
#
# Next we check for any software intrusions.
#
TRIPWIREFILE="/var/lib/tripwire/`uname -n 2>/dev/null`.twd"
if [ -f "${TRIPWIREFILE}" ]; then
ROOTKIT_COUNT=`expr $ROOTKIT_COUNT + 1`
if [ -z "`grep ${GREP_OPT} 'Tripwire segment-faulted !' \"${TRIPWIREFILE}\"`" ]; then
display --to SCREEN+LOG --type PLAIN --result NONE_FOUND --color GREEN --screen-indent 4 --log-indent 2 --log-nl ROOTKIT_MALWARE_SFW_INTRUSION
else
ROOTKIT_FAILED_COUNT=`expr ${ROOTKIT_FAILED_COUNT} + 1`
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --screen-indent 4 --log-indent 2 --log-nl ROOTKIT_MALWARE_SFW_INTRUSION
display --to LOG --type WARNING --log-indent 2 ROOTKIT_MALWARE_SFW_INTRUSION_FOUND "${TRIPWIREFILE}" 'Tripwire segment-faulted'
fi
else
display --to LOG --type PLAIN --result SKIPPED --log-indent 2 --log-nl ROOTKIT_MALWARE_SFW_INTRUSION
display --to LOG --type INFO ROOTKIT_MALWARE_SFW_INTRUSION_SKIP
fi
#
# Next, check for sniffer log files.
#
FOUND=0
FOUNDFILES=""
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --nl --log-indent 2 ROOTKIT_MALWARE_SNIFFER_LOG
fi
for FNAME in ${SNIFFER_FILES}; do
if [ -f "${FNAME}" ]; then
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -n "`echo \"${RTKT_FILE_WHITELIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
display --to LOG --type INFO FILE_PROP_WL "`name2text \"${FNAME}\"`" 'other_malware'
else
FOUND=1
FOUNDFILES="${FOUNDFILES} ${FNAME}"
fi
test $VERBOSE_LOGGING -eq 1 && display --to LOG --type PLAIN --result FOUND --log-indent 4 ROOTKIT_FILES_DIRS_FILE "`name2text \"${FNAME}\"`"
elif [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result NOT_FOUND --log-indent 4 ROOTKIT_FILES_DIRS_FILE "`name2text \"${FNAME}\"`"
fi
done
#
# Now display the results.
#
if [ $FOUND -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --result NONE_FOUND --color GREEN --screen-indent 4 --log-indent 2 ROOTKIT_MALWARE_SNIFFER
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --screen-indent 4 --log-indent 2 ROOTKIT_MALWARE_SNIFFER
for FNAME in ${FOUNDFILES}; do
display --to LOG --type WARNING ROOTKIT_MALWARE_SNIFFER_FOUND "`name2text \"${FNAME}\"`"
done
fi
#
# Next we check System V Shared Memory (Linux only for now).
#
if [ $LINUXOS -eq 1 ]; then
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --nl ROOTKIT_MALWARE_IPCS
fi
if [ -n "${IPCS_CMD}" ]; then
get_temp_file "${RKHTMPDIR}/ipcs.tmp"
IPCS_TMPFILE="${TEMPFILE}"
touch "${IPCS_TMPFILE}"
FOUND=0; echo $FOUND > "${IPCS_TMPFILE}"
if [ `LANG=C ${IPCS_CMD} -u 2>/dev/null | awk -F' ' '/segments allocated/ {print $3}'` -ne 0 ]; then
${IPCS_CMD} -m | grep "^0x" | while read RKH_SHM_KEY RKH_SHM_SHMID RKH_SHM_OWNER RKH_SHM_PERMS RKH_SHM_BYTES RKH_SHM_NATTACH RKH_SHM_STATUS; do
if [ $RKH_SHM_PERMS -eq 666 -a $RKH_SHM_BYTES -ge 1000000 ]; then
FOUND=1; echo $FOUND > "${IPCS_TMPFILE}"
${IPCS_CMD} -p | grep "^${RKH_SHM_SHMID}" | while read RKH_SHM_SHMID RKH_SHM_OWNER RKH_SHM_CPID RKH_SHM_LPID; do
RKH_SHM_PATH=`${READLINK_CMD} -f /proc/${RKH_SHM_CPID}/exe`
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result FOUND --log-indent 2 ROOTKIT_MALWARE_IPCS_DETAILS "${RKH_SHM_PATH}" "${RKH_SHM_CPID}" "${RKH_SHM_OWNER}"
fi
done
fi
done
fi
elif [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type INFO NOT_FOUND_CMD 'ipcs'
fi
#
# Now display the results.
#
if [ `cat "${IPCS_TMPFILE}"` -eq 1 ]; then
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --screen-indent 4 --log-indent 2 ROOTKIT_MALWARE_IPCS
else
display --to SCREEN+LOG --type PLAIN --result NONE_FOUND --color GREEN --screen-indent 4 --log-indent 2 ROOTKIT_MALWARE_IPCS
fi
rm -f "${IPCS_TMPFILE}"
fi
return
}
xinetd_include() {
#
# This function handles the xinetd 'include' directive.
# It is also used to initially process the xinetd.conf
# file, and to process any files within an 'includedir'
# directory.
#
# Any filename containing a dot or ending in a tilde (~)
# is ignored. Also absolute pathnames must be used.
#
FILENAME=$1
test -z "${FILENAME}" -o ! -f "${FILENAME}" && return
test -z "`echo \"${FILENAME}\" | grep '^/'`" && return
test -n "`echo \"${FILENAME}\" | grep '/[^/]*\.[^/]*$'`" -a "${FILENAME}" != "${XINETD_CONF_PATH}" && return
test -n "`echo \"${FILENAME}\" | grep '~$'`" && return
#
# First see if any defaults have been seen. Only the first instance is used.
#
SEEN=0
if [ $XINETD_DFLTS_SEEN -eq 0 ]; then
if [ -n "`grep '^defaults' \"${FILENAME}\"`" ]; then
XINETD_DFLTS_SEEN=1
IFS=$IFSNL
# Get the default enabled services.
for LINE in `egrep '^[ ]*enabled[ ]*\+?=' "${FILENAME}"`; do
SEEN=1
RKHTMPVAR=`echo "${LINE}" | sed -e 's/^.*=//' | tr -s ' ' ' '`
XINETD_DFLTS_ENABLED="${XINETD_DFLTS_ENABLED} ${RKHTMPVAR}"
done
# We must ensure that the enabled default is
# either the null string or set to something.
if [ -n "${XINETD_DFLTS_ENABLED}" ]; then
XINETD_DFLTS_ENABLED=`echo ${XINETD_DFLTS_ENABLED}`
test -n "${XINETD_DFLTS_ENABLED}" && XINETD_DFLTS_ENABLED=" ${XINETD_DFLTS_ENABLED} "
fi
# Get the default disabled services.
for LINE in `egrep '^[ ]*disabled[ ]*\+?=' "${FILENAME}"`; do
RKHTMPVAR=`echo "${LINE}" | sed -e 's/^.*=//' | tr -s ' ' ' '`
XINETD_DFLTS_DISABLED="${XINETD_DFLTS_DISABLED} ${RKHTMPVAR}"
done
# We must ensure that the disabled default is
# either the null string or set to something.
if [ -n "${XINETD_DFLTS_DISABLED}" ]; then
XINETD_DFLTS_DISABLED=`echo ${XINETD_DFLTS_DISABLED}`
test -n "${XINETD_DFLTS_DISABLED}" && XINETD_DFLTS_DISABLED=" ${XINETD_DFLTS_DISABLED} "
fi
IFS=$RKHIFS
fi
fi
#
# Now check to see if an actual service has been configured.
#
if [ -n "`grep '^service' \"${FILENAME}\"`" ]; then
IFS=$IFSNL
#
# We must dig out the service name and its 'id' for each service configured in the file.
#
for DATA in `awk '/^service/, /^[ ]*\}/ { if ($0 ~ /^[ ]*(#|$)/) next; printf "%s", $0; if ($0 ~ /\}/) print ""; }' "${FILENAME}"`; do
# Unfortunately we must jiggle with IFS again to ensure that subsequent commands work.
IFS=$RKHIFS
# We 'echo' the configured service to flatten out any whitespace.
RKHTMPVAR=`echo ${DATA} | cut -d' ' -f2 | sed -e 's/{$//'`
RKHTMPVAR2=`echo ${DATA} | sed -e 's/^.* id = \([^ ]*\).*$/\1/'`
if [ -z "${RKHTMPVAR2}" ]; then
SVCID=" ${RKHTMPVAR} "
else
SVCID=" (${RKHTMPVAR}|${RKHTMPVAR2}) "
fi
#
# We now check the service name and id against those listed in the defaults.
#
if [ -n "${XINETD_DFLTS_ENABLED}" ]; then
if [ -n "`echo \"${XINETD_DFLTS_ENABLED}\" | egrep \"${SVCID}\"`" ]; then
if [ -z "`echo \"${XINETD_DFLTS_DISABLED}\" | egrep \"${SVCID}\"`" ]; then
SEEN=1
IFS=$IFSNL
break
fi
fi
elif [ -n "`echo \"${XINETD_DFLTS_DISABLED}\" | egrep \"${SVCID}\"`" ]; then
:
elif [ -z "`echo $DATA | grep 'disable = yes'`" ]; then
SEEN=1
IFS=$IFSNL
break
fi
IFS=$IFSNL
done
IFS=$RKHIFS
fi
if [ $SEEN -eq 1 ]; then
#
# See if the file is whitelisted.
#
FOUNDWL=0
for FNAME in ${XINETDALLOWEDSVCS}; do
if [ "${FNAME}" = "${FILENAME}" ]; then
FOUNDWL=1
break
fi
done
if [ $FOUNDWL -eq 0 ]; then
FOUND=1
FOUNDFILES="${FOUNDFILES} ${FILENAME}"
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result WARNING --log-indent 4 ROOTKIT_TROJAN_XINETD_ENABLED "${FILENAME}"
fi
elif [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result NONE_FOUND --log-indent 4 ROOTKIT_TROJAN_XINETD_ENABLED "${FILENAME}"
display --to LOG --type INFO ROOTKIT_TROJAN_XINETD_WHITELIST "${FILENAME}" 'xinetd'
fi
elif [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --result NONE_FOUND --log-indent 4 ROOTKIT_TROJAN_XINETD_ENABLED "${FILENAME}"
fi
#
# Next we look for any 'include' directives.
#
for FNAME in `grep '^[ ]*include[ ]' "${FILENAME}" | awk '{ print $2 }'`; do
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --log-indent 6 ROOTKIT_TROJAN_XINETD_INCLUDE "${FNAME}"
fi
xinetd_include "${FNAME}"
done
#
# Finally we look for any 'includedir' directives.
#
for DIR in `grep '^[ ]*includedir[ ]' "${FILENAME}" | awk '{ print $2 }'`; do
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --log-indent 6 ROOTKIT_TROJAN_XINETD_INCLUDEDIR "${DIR}"
fi
xinetd_includedir "${DIR}"
done
return
}
xinetd_includedir() {
#
# This function handles the xinetd 'includedir' directive.
#
# Absolute pathnames must be used.
#
test -z "$1" -o ! -d "$1" && return
test -z "`echo \"$1\" | grep '^/'`" && return
for FNAME in `ls $1`; do
xinetd_include "$1/${FNAME}"
done
return
}
sol10_inetd() {
#
# This function handles the Solaris 10, and later, inetd
# configuration. Because the original inetd.conf file may
# well exist, we look in there as well for any enabled services.
#
# This function sets the FOUNDSTRING variable, which will
# be used later.
#
FOUNDSTRING=`${INETADM_CMD} | grep '^enabled' | cut -d: -f2`
if [ -f "${INETD_CONF_PATH}" ]; then
STR=`grep -v '^#' "${INETD_CONF_PATH}" | ${AWK_CMD} '{ print $1 }'`
#
# Remove any inetd services which we already know
# about from inetadm.
#
for RKHTMPVAR in ${STR}; do
if [ -z "`echo \"${FOUNDSTRING}\" | grep \"/${RKHTMPVAR}/\"`" ]; then
FOUNDSTRING="${FOUNDSTRING} ${RKHTMPVAR}"
fi
done
fi
return
}
trojan_checks() {
#
# This function performs some trojan specific checks.
#
if `check_test trojans`; then
if ! `check_test malware`; then
display --to SCREEN --type PLAIN --screen-indent 2 --nl ROOTKIT_MALWARE_START
fi
display --to LOG --type INFO --nl STARTING_TEST trojans
else
display --to LOG --type INFO --nl USER_DISABLED_TEST trojans
return
fi
#
# We first need to see if we are running Solaris 10 or later.
# Earlier versions of Solaris used the standard inetd configuration
# file, but later versions use a different mechanism. The 'inetadm'
# command can be used on these later Solaris versions.
#
if [ $SUNOS -eq 1 ]; then
INETADM_CMD=`find_cmd inetadm`
test -n "${INETADM_CMD}" && sol10_inetd
else
INETADM_CMD=""
fi
if [ -f "${INETD_CONF_PATH}" -o -f "${XINETD_CONF_PATH}" -o -n "${INETADM_CMD}" ]; then
RKHTMPVAR="SCREEN+LOG"
else
RKHTMPVAR="LOG"
fi
display --to "${RKHTMPVAR}" --type PLAIN --screen-indent 2 ROOTKIT_TROJAN_START
#
# We first check the inetd.conf file. This includes the
# Solaris 10 inetd services as well.
#
if [ -f "${INETD_CONF_PATH}" -o -n "${INETADM_CMD}" ]; then
if [ -z "${INETADM_CMD}" ]; then
display --to LOG --type INFO CONFIG_XINETD_PATH 'inetd' "${INETD_CONF_PATH}"
FOUNDSTRING=`grep -v '^#' "${INETD_CONF_PATH}" | awk '{ print $1 }'`
else
display --to LOG --type INFO CONFIG_SOL10_INETD
fi
#
# We now need to see if any of the services are whitelisted.
#
RKHTMPVAR=""
for STR in ${FOUNDSTRING}; do
FOUND=0
for SVC in ${INETDALLOWEDSVCS}; do
if [ "${STR}" = "${SVC}" ]; then
FOUND=1
display --to LOG --type INFO ROOTKIT_TROJAN_XINETD_WHITELIST "${SVC}" 'inetd'
break
fi
done
if [ $FOUND -eq 0 ]; then
#
# We want to change any RPC services into
# an actual executable name, if we can. The
# executable is the sixth field. If the
# sixth field is empty or this is an internal
# service, then we just use the service name.
#
if [ -n "`echo \"${STR}\" | grep '^[0-9/_-]*$'`" ]; then
EXECNAME=`grep "^${STR}" "${INETD_CONF_PATH}" | awk '{ print $6 }'`
test -z "${EXECNAME}" -o "${EXECNAME}" = "internal" && EXECNAME="${STR}"
STR="${EXECNAME}"
#
# Now check if the executable has been whitelisted.
#
for SVC in ${INETDALLOWEDSVCS}; do
if [ "${STR}" = "${SVC}" ]; then
FOUND=1
display --to LOG --type INFO ROOTKIT_TROJAN_XINETD_WHITELIST "${SVC}" 'inetd'
break
fi
done
fi
test $FOUND -eq 0 && RKHTMPVAR="${RKHTMPVAR} ${STR}"
fi
done
FOUNDSTRING="${RKHTMPVAR}"
#
# Now display the results.
#
if [ -z "${FOUNDSTRING}" ]; then
display --to SCREEN+LOG --type PLAIN --result OK --color GREEN --screen-indent 4 --log-indent 2 ROOTKIT_TROJAN_INETD
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --screen-indent 4 --log-indent 2 ROOTKIT_TROJAN_INETD
for STR in ${FOUNDSTRING}; do
display --to LOG --type WARNING ROOTKIT_TROJAN_INETD_FOUND "${STR}"
done
fi
else
display --to LOG --type PLAIN --result SKIPPED --log-indent 2 ROOTKIT_TROJAN_INETD
display --to LOG --type INFO ROOTKIT_TROJAN_INETD_SKIP "${INETD_CONF_PATH}"
fi
#
# Next we check the xinetd.conf file.
#
FOUND=0
FOUNDFILES=""
if [ $VERBOSE_LOGGING -eq 1 ]; then
display --to LOG --type PLAIN --nl --log-indent 2 ROOTKIT_TROJAN_XINETD_LOG
fi
if [ -f "${XINETD_CONF_PATH}" ]; then
XINETD_DFLTS_SEEN=0
XINETD_DFLTS_ENABLED=""
XINETD_DFLTS_DISABLED=""
display --to LOG --type INFO CONFIG_XINETD_PATH 'xinetd' "${XINETD_CONF_PATH}"
xinetd_include "${XINETD_CONF_PATH}"
#
# Now display the results.
#
if [ $FOUND -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --result NONE_FOUND --color GREEN --log-indent 2 --screen-indent 4 ROOTKIT_TROJAN_XINETD
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 ROOTKIT_TROJAN_XINETD
for FNAME in ${FOUNDFILES}; do
display --to LOG --type WARNING ROOTKIT_TROJAN_XINETD_ENABLED_FOUND "${FNAME}"
done
fi
else
display --to LOG --type PLAIN --result SKIPPED --log-indent 2 ROOTKIT_TROJAN_XINETD
display --to LOG --type INFO ROOTKIT_TROJAN_INETD_SKIP "${XINETD_CONF_PATH}"
fi
#
# Finally we check for an Apache backdoor module.
#
FOUND=0
FOUNDFILES=""
MOD_DIRS="/etc/apache2/mods-enabled /etc/httpd/modules /usr/apache/libexec /usr/lib/modules /usr/local/apache/modules"
HTTPDDIRS="/usr/local/apache/conf /usr/local/etc/apache /etc/apache /etc/httpd/conf"
for DIR in ${MOD_DIRS} ${HTTPDDIRS}; do
if [ -d "${DIR}" ]; then
FOUND=1
test -f "${DIR}/mod_rootme.so" && FOUNDFILES="${FOUNDFILES} ${DIR}/mod_rootme.so"
test -f "${DIR}/mod_rootme2.so" && FOUNDFILES="${FOUNDFILES} ${DIR}/mod_rootme2.so"
if [ -f "${DIR}/httpd.conf" ]; then
if [ -n "`egrep 'mod_rootme2?\.so' \"${DIR}/httpd.conf\"`" ]; then
FOUNDFILES="${FOUNDFILES} ${DIR}/httpd.conf"
fi
fi
fi
done
#
# Now display the results.
#
if [ $FOUND -eq 0 ]; then
display --to LOG --type INFO ROOTKIT_TROJAN_APACHE_SKIPPED
elif [ -z "${FOUNDFILES}" ]; then
display --to SCREEN+LOG --type PLAIN --result NOT_FOUND --color GREEN --log-indent 2 --screen-indent 4 ROOTKIT_TROJAN_APACHE
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 ROOTKIT_TROJAN_APACHE
for FILE in ${FOUNDFILES}; do
display --to LOG --type WARNING ROOTKIT_TROJAN_APACHE_FOUND "`name2text \"${FILE}\"`"
done
fi
return
}
bsd_specific_checks() {
#
# This function performs tests specific to the BSD O/S.
#
#
# We check that the output of sockstat and netstat for
# local listening sockets is the same.
#
SOCKSTAT_CMD=`find_cmd sockstat`
if [ -n "${SOCKSTAT_CMD}" -a -n "${NETSTAT_CMD}" ]; then
test "${OPERATING_SYSTEM}" = "NetBSD" && RKHTMPVAR="-n" || RKHTMPVAR=""
SOCKSTAT_OUTPUT=`${SOCKSTAT_CMD} ${RKHTMPVAR} | awk '$5 ~ /^(tcp|udp)/ { if ($6 == 6) print $7; else print $6 }'`
SOCKSTAT_OUTPUT=`echo "${SOCKSTAT_OUTPUT}" | grep '[:.][0-9][0-9]*$' | sed -e 's/^.*[:.]\([0-9]*\)$/\1/' | sort | uniq`
NETSTAT_OUTPUT=`${NETSTAT_CMD} -an | awk '$1 ~ /^(tcp|udp)/ { print $4 }' | grep '[:.][0-9][0-9]*$' | sed -e 's/^.*[:.]\([0-9]*\)$/\1/' | sort | uniq`
if [ "${SOCKSTAT_OUTPUT}" = "${NETSTAT_OUTPUT}" ]; then
display --to SCREEN+LOG --type PLAIN --result OK --color GREEN --log-indent 2 --screen-indent 4 ROOTKIT_OS_BSD_SOCKNET
else
SOCKSTAT_OUTPUT=`echo ${SOCKSTAT_OUTPUT}`
NETSTAT_OUTPUT=`echo ${NETSTAT_OUTPUT}`
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 ROOTKIT_OS_BSD_SOCKNET
display --to LOG --type WARNING ROOTKIT_OS_BSD_SOCKNET_FOUND
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_OS_BSD_SOCKNET_OUTPUT 'Sockstat' "${SOCKSTAT_OUTPUT}"
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_OS_BSD_SOCKNET_OUTPUT 'Netstat' "${NETSTAT_OUTPUT}"
fi
else
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --log-indent 2 --screen-indent 4 ROOTKIT_OS_BSD_SOCKNET
test -z "${SOCKSTAT_CMD}" && display --to LOG --type INFO NOT_FOUND_CMD 'sockstat'
test -z "${NETSTAT_CMD}" && display --to LOG --type INFO NOT_FOUND_CMD 'netstat'
fi
return
}
freebsd_specific_checks() {
#
# This function performs tests specific to the FreeBSD O/S.
#
#
# First we check for KLD backdoors.
#
KLDSTAT_CMD=`find_cmd kldstat`
if [ -n "${KLDSTAT_CMD}" ]; then
FOUND=0
FOUNDKEYS=""
for RKHTMPVAR in ${KLDSTATKEYWORDS}; do
RKHTMPVAR=`echo ${RKHTMPVAR}`
KLDKEYWD=`echo ${RKHTMPVAR} | sed -e 's/\./\\\./g'`
if [ -n "`${KLDSTAT_CMD} -v | grep \"${KLDKEYWD}\"`" ]; then
FOUND=1
FOUNDKEYS="${FOUNDKEYS} ${RKHTMPVAR} "
fi
done
if [ $FOUND -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --result OK --color GREEN --log-indent 2 --screen-indent 4 ROOTKIT_OS_FREEBSD_KLD
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 ROOTKIT_OS_FREEBSD_KLD
for RKHTMPVAR in ${FOUNDKEYS}; do
display --to LOG --type WARNING ROOTKIT_OS_FREEBSD_KLD_FOUND "${RKHTMPVAR}"
done
fi
else
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --log-indent 2 --screen-indent 4 ROOTKIT_OS_FREEBSD_KLD
display --to LOG --type INFO NOT_FOUND_CMD 'kldstat'
fi
#
# Next we check that the package database is okay.
#
if [ "${OPERATING_SYSTEM}" = "DragonFly" ]; then
PKGDB_CMD=`find_cmd pkg_admin`
if [ -n "${PKGDB_CMD}" ]; then
RKHTMPVAR=`${PKGDB_CMD} check 2>&1 >/dev/null`
if [ -z "${RKHTMPVAR}" ]; then
display --to SCREEN+LOG --type PLAIN --result OK --color GREEN --log-indent 2 --screen-indent 4 ROOTKIT_OS_FREEBSD_PKGDB
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 ROOTKIT_OS_FREEBSD_PKGDB
display --to LOG --type WARNING ROOTKIT_OS_DFLY_PKGDB_NOTOK
fi
else
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --log-indent 2 --screen-indent 4 ROOTKIT_OS_FREEBSD_PKGDB
display --to LOG --type INFO NOT_FOUND_CMD 'pkg_admin'
fi
else
PKGDB_CMD=`find_cmd pkgdb`
if [ -n "${PKGDB_CMD}" ]; then
RKHTMPVAR=`${PKGDB_CMD} -Fa -v 2>&1 | grep 'Skipped\.'`
if [ -z "${RKHTMPVAR}" ]; then
display --to SCREEN+LOG --type PLAIN --result OK --color GREEN --log-indent 2 --screen-indent 4 ROOTKIT_OS_FREEBSD_PKGDB
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 ROOTKIT_OS_FREEBSD_PKGDB
display --to LOG --type WARNING ROOTKIT_OS_FREEBSD_PKGDB_NOTOK
fi
else
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --log-indent 2 --screen-indent 4 ROOTKIT_OS_FREEBSD_PKGDB
display --to LOG --type INFO NOT_FOUND_CMD 'pkgdb'
fi
fi
return
}
linux_loaded_modules() {
#
# This test checks the currently loaded kernel modules. It verifies
# that what is seen by the 'lsmod' command is the same as seen in
# the /proc/modules directory.
#
if ! `check_test loaded_modules`; then
display --to LOG --type INFO --nl USER_DISABLED_TEST loaded_modules
return
fi
if [ ! -f "/proc/modules" ]; then
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 ROOTKIT_OS_LINUX_LKM
display --to LOG --type WARNING ROOTKIT_OS_LINUX_LKM_MOD_MISSING '/proc/modules'
elif [ -z "${LSMOD_CMD}" ]; then
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --log-indent 2 --screen-indent 4 ROOTKIT_OS_LINUX_LKM
test -z "${LSMOD_CMD}" && display --to LOG --type INFO NOT_FOUND_CMD 'lsmod'
else
PROC_OUTPUT=`cat /proc/modules | cut -d' ' -f1 | sort`
LSMOD_OUTPUT=`${LSMOD_CMD} | grep -v 'Size *Used *by' | cut -d' ' -f1 | sort`
if [ -n "${PROC_OUTPUT}" -a -n "${LSMOD_OUTPUT}" ]; then
if [ "${PROC_OUTPUT}" = "${LSMOD_OUTPUT}" ]; then
display --to SCREEN+LOG --type PLAIN --result OK --color GREEN --log-indent 2 --screen-indent 4 ROOTKIT_OS_LINUX_LKM
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 ROOTKIT_OS_LINUX_LKM
display --to LOG --type WARNING ROOTKIT_OS_LINUX_LKM_FOUND
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_OS_LINUX_LKM_OUTPUT '/proc/modules' "${PROC_OUTPUT}"
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_OS_LINUX_LKM_OUTPUT 'lsmod' "${LSMOD_OUTPUT}"
fi
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 ROOTKIT_OS_LINUX_LKM
display --to LOG --type WARNING ROOTKIT_OS_LINUX_LKM_EMPTY
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_OS_LINUX_LKM_OUTPUT '/proc/modules' "${PROC_OUTPUT}"
display --to LOG --type PLAIN --log-indent 9 ROOTKIT_OS_LINUX_LKM_OUTPUT 'lsmod' "${LSMOD_OUTPUT}"
fi
fi
return
}
linux_avail_modules() {
#
# This test checks the names of the kernel
# modules that are available on this system.
#
if ! `check_test avail_modules`; then
display --to LOG --type INFO --nl USER_DISABLED_TEST avail_modules
return
fi
#
# First obtain and log where the modules are kept. This can
# be set in the configuration file, but generally rkhunter
# will determine the location based on the kernel version.
# However, in the case of remote diagnostics the diagnosing
# and diagnosed kernel versions may be different. In this
# case we simply look in '/lib/modules'.
#
FOUND=0
FOUNDFILES=""
LKM_NAMES=""
display --to LOG --type INFO ROOTKIT_OS_LINUX_LKMNAMES_PATH "${LKM_PATH}"
#
# We reformat the LKM names at this point
# since we only need to do it once.
#
for RKHTMPVAR in ${LKM_BADNAMES}; do
RKHTMPVAR=`echo ${RKHTMPVAR} | sed -e 's/\./\\\./g'`
LKM_NAMES="${LKM_NAMES} ${RKHTMPVAR}"
done
#
# Now do the test.
#
if [ ! -d "${LKM_PATH}" ]; then
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 ROOTKIT_OS_LINUX_LKMNAMES
display --to LOG --type WARNING ROOTKIT_OS_LINUX_LKMNAMES_PATH_MISSING "${LKM_PATH}"
elif [ -z "${FIND_CMD}" ]; then
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --log-indent 2 --screen-indent 4 ROOTKIT_OS_LINUX_LKMNAMES
display --to LOG --type INFO NOT_FOUND_CMD 'find'
elif [ -z "`ls -1 \"${LKM_PATH}\" 2>/dev/null`" ]; then
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --log-indent 2 --screen-indent 4 ROOTKIT_OS_LINUX_LKMNAMES
display --to LOG --type WARNING ROOTKIT_OS_LINUX_LKMNAMES_PATH_MISSING "${LKM_PATH}"
else
for FNAME in `${FIND_CMD} "${LKM_PATH}" -type f -name "*.o" 2>/dev/null`; do
for RKHTMPVAR in ${LKM_NAMES}; do
if [ -n "`echo ${FNAME} | grep \"/${RKHTMPVAR}$\"`" ]; then
FOUND=1
FOUNDFILES="${FOUNDFILES} ${RKHTMPVAR}"
fi
done
done
if [ $FOUND -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --result OK --color GREEN --log-indent 2 --screen-indent 4 ROOTKIT_OS_LINUX_LKMNAMES
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 ROOTKIT_OS_LINUX_LKMNAMES
for RKHTMPVAR in ${FOUNDFILES}; do
RKHTMPVAR=`echo "${RKHTMPVAR}" | sed -e 's/\\\././g'`
display --to LOG --type WARNING ROOTKIT_OS_LINUX_LKMNAMES_FOUND "${LKM_PATH}" "${RKHTMPVAR}"
done
fi
fi
return
}
linux_specific_checks() {
#
# This function performs tests specific to the Linux O/S.
#
linux_loaded_modules
linux_avail_modules
return
}
os_specific_checks() {
#
# This function performs any O/S specific tests.
#
if `check_test os_specific`; then
display --to LOG --type INFO --screen-nl --nl STARTING_TEST os_specific
else
display --to LOG --type INFO --nl USER_DISABLED_TEST os_specific
return
fi
#
# Run the relevant O/S specific tests.
#
case "${OPERATING_SYSTEM}" in
FreeBSD|NetBSD|DragonFly)
display --to SCREEN+LOG --type PLAIN --screen-indent 2 ROOTKIT_OS_START "${OPERATING_SYSTEM}"
bsd_specific_checks
test "${OPERATING_SYSTEM}" = "FreeBSD" -o "${OPERATING_SYSTEM}" = "DragonFly" && freebsd_specific_checks
;;
Linux)
display --to SCREEN+LOG --type PLAIN --screen-indent 2 ROOTKIT_OS_START "${OPERATING_SYSTEM}"
linux_specific_checks
;;
*)
display --to SCREEN+LOG --type PLAIN --screen-indent 2 --color YELLOW --result SKIPPED ROOTKIT_OS_START "${OPERATING_SYSTEM}"
display --to LOG --type INFO ROOTKIT_OS_SKIPPED
;;
esac
return
}
do_rootkit_checks() {
#
# This function carries out a sequence of tests for rootkits.
# This consists of the default files and directories check,
# possible rootkit checks, and checks for malware.
#
if `check_test rootkits`; then
display --to LOG --type INFO --screen-nl --nl STARTING_TEST rootkits
display --to SCREEN+LOG --type PLAIN --color YELLOW CHECK_ROOTKITS
else
display --to LOG --type INFO --nl USER_DISABLED_TEST rootkits
return
fi
rootkit_file_dir_checks
check_test known_rkts || check_test all && keypresspause
additional_rootkit_checks
malware_checks
trojan_checks
os_specific_checks
keypresspause
return
}
check_port_wl() {
#
# This function tries to find the PID and command pathname using
# a given port. It then checks to see if the port is whitelisted.
#
# A single parameter indicates if we are in the 'hidden_ports'
# test or not.
#
PID=0
PID_SEEN=0
FNAME=""
FOUND=""
IN_HIDDEN_PORTS=$1
if [ -n "${LSOF_CMD}" ]; then
IFS=$IFSNL
for LSOFLINE in `${LSOF_CMD} -wnlP -i ${PROTO}:${PORT}`; do
#
# We must only look at connections using the port on the local host.
#
if [ -n "`echo \"${LSOFLINE}\" | grep \" ${PROTO} \*:${PORT} \"`" ]; then
# Process listening for connections from anywhere.
PID=`echo "${LSOFLINE}" | awk '{ print $2 }'`
elif [ -n "`echo \"${LSOFLINE}\" | egrep \" ${PROTO} [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:${PORT}[ -]\"`" ]; then
# Established or listening process using IPv4 address.
PID=`echo "${LSOFLINE}" | awk '{ print $2 }'`
elif [ -n "`echo \"${LSOFLINE}\" | egrep \" ${PROTO} \[[:0-9a-fA-F]+\]:${PORT}[ -]\"`" ]; then
# Established or listening process using IPv6 address.
PID=`echo "${LSOFLINE}" | awk '{ print $2 }'`
else
# Ignore anything else.
continue
fi
PID_SEEN=1
#
# Try and get the running process name.
#
if [ $HAVE_READLINK -eq 1 ]; then
RKHTMPVAR=""
if [ $SOL_PROC -eq 1 ]; then
test -h "/proc/${PID}/path/a.out" && RKHTMPVAR=`${READLINK_CMD} -f "/proc/${PID}/path/a.out"`
elif [ $SUNOS -eq 0 -o -h "/proc/${PID}/exe" ]; then
test -h "/proc/${PID}/exe" && RKHTMPVAR=`${READLINK_CMD} -f "/proc/${PID}/exe"`
fi
test -n "${RKHTMPVAR}" && FNAME=`echo "${RKHTMPVAR}" | cut -d' ' -f1`
fi
if [ -z "${FNAME}" ]; then
if [ $SUNOS -eq 1 ]; then
FNAME=`${LSOF_CMD} -wnlP +c 0 -p $PID | grep '[ ]txt[ ][ ]*VREG[ ]' | head ${HEAD_OPT}1 | ${AWK_CMD} '{ print $NF }'`
else
FNAME=`${LSOF_CMD} -wnlP +c 0 -p $PID | grep '[ ]txt[ ][ ]*REG[ ]' | awk '{ print $NF }'`
fi
fi
if [ -n "`echo \"${FNAME}\" | grep '^/'`" ]; then
FOUND="${FNAME}"
break
fi
done
IFS=$RKHIFS
if [ -z "${FOUND}" -a $PID_SEEN -eq 1 ]; then
FNAME=""
FOUND="${PROTO}:${PORT}"
fi
elif [ $IN_HIDDEN_PORTS -eq 1 ]; then
# The 'netstat' command offers us no further information
# on hidden ports, so we can skip it.
:
else
case "${OPERATING_SYSTEM}" in
Linux)
FOUND=`${NETSTAT_CMD} -an | grep -i "^${PROTO}.*:${PORT} " | awk '{ print $4 }' | grep ":${PORT}$"`
;;
*BSD|Darwin|IRIX*|DragonFly)
FOUND=`${NETSTAT_CMD} -an | grep -i "^${PROTO}.*\.${PORT} " | awk '{ print $4 }' | grep "\.${PORT}$"`
;;
AIX)
if [ "${PROTO}" = "UDP" ]; then
FOUND=`${NETSTAT_CMD} -an | grep -i "^udp.*\.${PORT} " | awk '{ print $4 }' | grep "\.${PORT}$"`
elif [ "${PROTO}" = "TCP" ]; then
FOUND=`${NETSTAT_CMD} -an | egrep -i "^tcp.*\.${PORT} .*(BOUND|ESTABLISH|LISTEN)" | awk '{ print $4 }' | grep "\.${PORT}$"`
fi
;;
SunOS)
if [ "${PROTO}" = "UDP" ]; then
FOUND=`${NETSTAT_CMD} -an | ${AWK_CMD} '/^UDP: IPv4/, /^$/ { print $1 }' | grep "\.${PORT}$"`
if [ -z "${FOUND}" ]; then
FOUND=`${NETSTAT_CMD} -an | ${AWK_CMD} '/^UDP: IPv6/, /^$/ { print $1 }' | grep "\.${PORT}$"`
fi
elif [ "${PROTO}" = "TCP" ]; then
FOUND=`${NETSTAT_CMD} -an | ${AWK_CMD} '/^TCP: IPv4/, /^$/ { print $0 }' | egrep 'BOUND|ESTABLISH|LISTEN' | ${AWK_CMD} '{ print $1 }' | grep "\.${PORT}$"`
if [ -z "${FOUND}" ]; then
FOUND=`${NETSTAT_CMD} -an | ${AWK_CMD} '/^TCP: IPv6/, /^$/ { print $0 }' | egrep 'BOUND|ESTABLISH|LISTEN' | ${AWK_CMD} '{ print $1 }' | grep "\.${PORT}$"`
fi
fi
;;
esac
fi
#
# If we have found something, then see if it is whitelisted.
#
if [ -n "${FOUND}" -o $IN_HIDDEN_PORTS -eq 1 ]; then
RKHTMPVAR2=0
if [ -n "${LSOF_CMD}" ]; then
if [ -n "${FNAME}" ]; then
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -n "`echo \"${PORT_WHITELIST}\" | grep \"^${FNAMEGREP}:${PROTO}:${PORT}$\"`" ]; then
RKHTMPVAR2=1
FOUND="path_whitelisted"
elif [ -n "`echo \"${PORT_WHITELIST}\" | grep \"^${FNAMEGREP}$\"`" ]; then
RKHTMPVAR2=1
FOUND="path_whitelisted"
elif [ $PORT_WHITELIST_ALL_TRUSTED -eq 1 ]; then
test -n "${BASENAME_CMD}" && RKHTMPVAR=`${BASENAME_CMD} "${FNAME}"` || RKHTMPVAR=`echo "${FNAME}" | sed -e 's:^.*/::'`
RKHTMPVAR=`IFS=$RKHIFS find_cmd ${RKHTMPVAR}`
if [ "${RKHTMPVAR}" = "${FNAME}" ]; then
RKHTMPVAR2=1
FOUND="trusted_whitelisted"
fi
fi
fi
fi
if [ $RKHTMPVAR2 -eq 0 -a -n "`echo \"${PORT_WHITELIST}\" | grep \"^${PROTO}:${PORT}$\"`" ]; then
FOUND="port_whitelisted"
fi
fi
return
}
do_network_port_checks() {
#
# This function will check the network ports to see
# if any known backdoor ports are being used.
#
if `check_test ports || check_test hidden_ports`; then
display --to SCREEN+LOG --type PLAIN --screen-indent 2 --nl NETWORK_PORTS_START
fi
if `check_test ports`; then
display --to LOG --type INFO STARTING_TEST ports
display --to LOG --type PLAIN --log-indent 2 NETWORK_PORTS_BACKDOOR_LOG
else
display --to LOG --type INFO --nl USER_DISABLED_TEST ports
return
fi
#
# We must first check to see if we can perform this test.
#
if [ -z "${LSOF_CMD}" -a -z "${NETSTAT_CMD}" ]; then
display --to SCREEN+LOG --type PLAIN --log-indent 2 --screen-indent 4 --color YELLOW --result SKIPPED NETWORK_PORTS_BACKDOOR
display --to LOG --type INFO TEST_SKIPPED_OS 'network port checks' 'lsof or netstat command required.'
return
fi
#
# Check that the backdoor ports data file is usable.
#
if [ ! -e "${DB_PATH}/backdoorports.dat" -o ! -s "${DB_PATH}/backdoorports.dat" ]; then
display --to SCREEN+LOG --type PLAIN --log-indent 2 --screen-indent 4 --color RED --result WARNING NETWORK_PORTS_BACKDOOR
display --to LOG --type WARNING NETWORK_PORTS_FILE_MISSING "${DB_PATH}/backdoorports.dat"
return
elif [ ! -f "${DB_PATH}/backdoorports.dat" -o -h "${DB_PATH}/backdoorports.dat" ]; then
display --to SCREEN+LOG --type PLAIN --log-indent 2 --screen-indent 4 --color RED --result WARNING NETWORK_PORTS_BACKDOOR
display --to LOG --type WARNING NETWORK_PORTS_FILE_NOTAFILE "${DB_PATH}/backdoorports.dat"
return
fi
#
# Next we do some further testing and the initial logging.
#
if [ -z "${LSOF_CMD}" ]; then
case "${OPERATING_SYSTEM}" in
*BSD|Linux|AIX|SunOS|Darwin|IRIX*|DragonFly)
;;
*)
display --to SCREEN+LOG --type PLAIN --log-indent 2 --screen-indent 4 --color RED --result WARNING NETWORK_PORTS_BACKDOOR
display --to LOG --type WARNING NETWORK_PORTS_UNKNOWN_NETSTAT
return
;;
esac
fi
test $PORT_WHITELIST_ALL_TRUSTED -eq 1 && display --to LOG --type INFO NETWORK_PORTS_ENABLE_TRUSTED
#
# Now do the test.
#
FOUNDPORT=0
IFS=$IFSNL
for LINE in `cat "${DB_PATH}/backdoorports.dat"`; do
if [ -z "`echo \"${LINE}\" | grep '^[0-9][0-9]*:'`" ]; then
continue
fi
PORT=`echo "${LINE}" | cut -d: -f1`
DESCRIPTION=`echo "${LINE}" | cut -d: -f2`
PROTO=`echo "${LINE}" | cut -d: -f3 | tr '[:lower:]' '[:upper:]'`
ROOTKIT_COUNT=`expr $ROOTKIT_COUNT + 1`
if [ -z "`echo \"${PORT}\" | grep '^[1-9][0-9]*$'`" ]; then
echo "Error: Invalid port in backdoorports.dat file: $LINE"
continue
elif [ "${PROTO}" != "UDP" -a "${PROTO}" != "TCP" ]; then
echo "Error: Invalid protocol in backdoorports.dat file: $LINE"
continue
fi
check_port_wl 0
# We need to reset IFS because it is set in 'check_port_wl'.
IFS=$IFSNL
#
# Now log the result.
#
case "${FOUND}" in
path_whitelisted)
display --to LOG --type INFO NETWORK_PORTS_PATH_WHITELIST "${PROTO}" "${PORT}" "`name2text \"${FNAME}\"`"
display --to LOG --type PLAIN --log-indent 4 --result WHITELISTED NETWORK_PORTS_BACKDOOR_CHK "${PROTO}" "${PORT}"
;;
trusted_whitelisted)
display --to LOG --type INFO NETWORK_PORTS_TRUSTED_WHITELIST "${PROTO}" "${PORT}" "`name2text \"${FNAME}\"`"
display --to LOG --type PLAIN --log-indent 4 --result WHITELISTED NETWORK_PORTS_BACKDOOR_CHK "${PROTO}" "${PORT}"
;;
port_whitelisted)
display --to LOG --type INFO NETWORK_PORTS_PORT_WHITELIST "${PROTO}" "${PORT}"
display --to LOG --type PLAIN --log-indent 4 --result WHITELISTED NETWORK_PORTS_BACKDOOR_CHK "${PROTO}" "${PORT}"
;;
"")
display --to LOG --type PLAIN --log-indent 4 --result NOT_FOUND NETWORK_PORTS_BACKDOOR_CHK "${PROTO}" "${PORT}"
;;
*)
FOUNDPORT=1
ROOTKIT_FAILED_COUNT=`expr $ROOTKIT_FAILED_COUNT + 1`
display --to LOG --type PLAIN --log-indent 4 --result FOUND NETWORK_PORTS_BACKDOOR_CHK "${PROTO}" "${PORT}"
test -n "${FNAME}" && FNAME=" by `name2text \"${FNAME}\"`"
display --to LOG --type WARNING NETWORK_PORTS_BKDOOR_FOUND "${PROTO}" "${PORT}" "${FNAME}" "${DESCRIPTION}"
;;
esac
done
IFS=$RKHIFS
#
# Finally show the overall result on the screen.
#
if [ $FOUNDPORT -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --log-indent 2 --screen-indent 4 --color GREEN --result NONE_FOUND NETWORK_PORTS_BACKDOOR
else
display --to SCREEN+LOG --type PLAIN --log-indent 2 --screen-indent 4 --color RED --result WARNING NETWORK_PORTS_BACKDOOR
fi
return
}
do_network_hidden_port_checks() {
#
# This function will check the network
# ports to see if any are being hidden.
#
if `check_test hidden_ports`; then
display --to LOG --type INFO --nl STARTING_TEST hidden_ports
else
display --to LOG --type INFO --nl USER_DISABLED_TEST hidden_ports
return
fi
#
# We must first check to see if we can perform this test.
#
UNHIDETCP_CMD=`find_cmd unhide-tcp`
if [ -n "${UNHIDETCP_CMD}" ]; then
display --to LOG --type INFO FOUND_CMD 'unhide-tcp' "${UNHIDETCP_CMD} ${UNHIDETCP_OPTS}"
else
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --screen-indent 4 NETWORK_HIDDEN_PORTS
display --to LOG --type INFO NOT_FOUND_CMD 'unhide-tcp'
return
fi
if [ $SUNOS -eq 1 ]; then
if [ "${AWK_CMD}" = "awk" ]; then
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --screen-indent 4 NETWORK_HIDDEN_PORTS
display --to LOG --type INFO NOT_FOUND_CMD 'gawk or nawk'
return
else
display --to LOG --type INFO FOUND_CMD 'awk' "${AWK_CMD}"
fi
fi
#
# We don't *need* the 'lsof' command to perform this test, but
# if it is available then it will be used to find out pathnames.
#
test $PORT_WHITELIST_ALL_TRUSTED -eq 1 && display --to LOG --type INFO NETWORK_PORTS_ENABLE_TRUSTED
#
# Now perform the test. We must do this in two parts
# to pick out the TCP ports, and then the UDP ports.
#
RKHTMPVAR=`${UNHIDETCP_CMD} ${UNHIDETCP_OPTS} 2>&1`
TCP_PORTS=`echo "${RKHTMPVAR}" | ${AWK_CMD} '/^(\[\*\])?Starting TCP check/, /^(\[\*\])?Starting UDP check/ { print $0 }' | grep '^Found ' | cut -d: -f2`
UDP_PORTS=`echo "${RKHTMPVAR}" | ${AWK_CMD} '/^(\[\*\])?Starting UDP check/, 0 { print $0 }' | grep '^Found ' | cut -d: -f2`
if [ -z "${TCP_PORTS}" -a -z "${UDP_PORTS}" ]; then
display --to SCREEN+LOG --type PLAIN --result NONE_FOUND --color GREEN --log-indent 2 --screen-indent 4 NETWORK_HIDDEN_PORTS
else
FOUND_PORTS=""
for PROTO in TCP UDP; do
HIDDEN_PORTS=`eval echo "\\$${PROTO}_PORTS"`
test -z "${HIDDEN_PORTS}" && continue
HIDDEN_PORTS=`echo ${HIDDEN_PORTS} | tr ' ' '\n' | sort | uniq`
HIDDEN_PORTS=`echo ${HIDDEN_PORTS}`
for PORT in ${HIDDEN_PORTS}; do
check_port_wl 1
#
# Now log the result.
#
case "${FOUND}" in
path_whitelisted)
display --to LOG --type INFO NETWORK_HIDDEN_PORTS_PATH_WHITELIST "${PROTO}" "${PORT}" "`name2text \"${FNAME}\"`"
;;
trusted_whitelisted)
display --to LOG --type INFO NETWORK_HIDDEN_PORTS_TRUSTED_WHITELIST "${PROTO}" "${PORT}" "`name2text \"${FNAME}\"`"
;;
port_whitelisted)
display --to LOG --type INFO NETWORK_HIDDEN_PORTS_PORT_WHITELIST "${PROTO}" "${PORT}"
;;
*)
FOUND_PORTS="${FOUND_PORTS}
${PROTO}:${PORT}:${FNAME}"
;;
esac
done
done
if [ -z "${FOUND_PORTS}" ]; then
display --to SCREEN+LOG --type PLAIN --result NONE_FOUND --color GREEN --log-indent 2 --screen-indent 4 NETWORK_HIDDEN_PORTS
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 NETWORK_HIDDEN_PORTS
display --to LOG --type WARNING --log-indent 2 NETWORK_HIDDEN_PORTS_FOUND
IFS=$IFSNL
FOUND_PORTS=`echo "${FOUND_PORTS}" | sed -e '/^$/d'`
for RKHTMPVAR in ${FOUND_PORTS}; do
PROTO=`echo ${RKHTMPVAR} | cut -d: -f1`
PORT=`echo ${RKHTMPVAR} | cut -d: -f2`
FNAME=`echo ${RKHTMPVAR} | cut -d: -f3-`
if [ -z "${FNAME}" ]; then
display --to LOG --type PLAIN --log-indent 9 NETWORK_HIDDEN_PORTS_CHK "${PROTO}" "${PORT}"
else
display --to LOG --type PLAIN --log-indent 9 NETWORK_HIDDEN_PORTS_CHK_NAME "${PROTO}" "${PORT}" "`name2text \"${FNAME}\"`"
fi
done
IFS=$RKHIFS
fi
fi
return
}
do_network_interface_checks() {
#
# This function will check the network interfaces to see
# if any are in promiscuous mode. It will also check to see
# if there are any applications running which are capturing
# network interface packets.
#
if `check_test promisc || check_test packet_cap_apps`; then
display --to SCREEN+LOG --type PLAIN --screen-indent 2 --nl NETWORK_INTERFACE_START
fi
if `check_test promisc`; then
display --to LOG --type INFO STARTING_TEST promisc
if [ -n "${IFCONFIG_CMD}" -o \( $LINUXOS -eq 1 -a -n "${IP_CMD}" \) ]; then
PROMISCSCAN1=""
PROMISCSCAN2=""
if [ -n "${IFCONFIG_CMD}" ]; then
if [ -n "${IFWLIST}" ]; then
display --to LOG --type INFO NETWORK_PROMISC_WLIST "${IFWLIST}"
IFWLIST=`echo "${IFWLIST}" | tr ' ' '|'`
fi
case "${OPERATING_SYSTEM}" in
*BSD|DragonFly)
if [ -z "${IFWLIST}" ]; then
PROMISCSCAN1=`${IFCONFIG_CMD} -a 2>&1 | awk '$1 !~ /^pflog/ && /PROMISC/ { print }'`
else
PROMISCSCAN1=`${IFCONFIG_CMD} -a 2>&1 | awk '$1 !~ /^pflog/ && $1 !~ /^('${IFWLIST}'):$/ && /PROMISC/ { print }'`
fi
;;
SunOS|IRIX*|AIX)
if [ -z "${IFWLIST}" ]; then
PROMISCSCAN1=`${IFCONFIG_CMD} -a 2>&1 | ${AWK_CMD} '/PROMISC/ { print }'`
else
PROMISCSCAN1=`${IFCONFIG_CMD} -a 2>&1 | ${AWK_CMD} '$1 !~ /^('${IFWLIST}'):$/ && /PROMISC/ { print }'`
fi
;;
*)
if [ -z "${IFWLIST}" ]; then
PROMISCSCAN1=`${IFCONFIG_CMD} 2>&1 | awk 'BEGIN { RS="" }; /PROMISC/ { print }'`
else
PROMISCSCAN1=`${IFCONFIG_CMD} 2>&1 | awk 'BEGIN { RS="" }; $1 !~ /^('${IFWLIST}'):?$/ && /PROMISC/ { print }'`
fi
;;
esac
else
display --to LOG --type INFO NETWORK_PROMISC_NO_CMD ifconfig ip
fi
if [ $LINUXOS -eq 1 ]; then
if [ -n "${IP_CMD}" ]; then
PROMISCSCAN2=`${IP_CMD} link | grep '^[0-9]' | grep -vE "^[0-9][0-9]*: (${IFWLIST}):" | grep 'PROMISC'`
else
display --to LOG --type INFO NETWORK_PROMISC_NO_CMD ip ifconfig
fi
fi
#
# Now show the results of the interface check.
#
if [ -z "${PROMISCSCAN1}" -a -z "${PROMISCSCAN2}" ]; then
display --to SCREEN+LOG --type PLAIN --color GREEN --result NONE_FOUND --log-indent 2 --screen-indent 4 NETWORK_PROMISC_CHECK
else
display --to SCREEN+LOG --type PLAIN --color RED --result WARNING --log-indent 2 --screen-indent 4 NETWORK_PROMISC_CHECK
display --to LOG --type WARNING NETWORK_PROMISC_IF
if [ -n "${PROMISCSCAN1}" ]; then
display --to LOG --type PLAIN --log-indent 9 NETWORK_PROMISC_IF_1
PROMISCSCAN1=`echo "${PROMISCSCAN1}" | awk '$0 !~ /^ / || /PROMISC/ { print }'`
IFS=$IFSNL
for IFACE in ${PROMISCSCAN1}; do
display --to LOG --type PLAIN --log-indent 13 NAME "${IFACE}"
done
IFS=$RKHIFS
fi
if [ -n "${PROMISCSCAN2}" ]; then
display --to LOG --type PLAIN --log-indent 9 NETWORK_PROMISC_IF_2
PROMISCSCAN2=`echo "${PROMISCSCAN2}" | cut -d: -f2-`
IFS=$IFSNL
# Only indent by 12 spaces here because the output starts with a space.
for IFACE in ${PROMISCSCAN2}; do
display --to LOG --type PLAIN --log-indent 12 NAME "${IFACE}"
done
IFS=$RKHIFS
fi
fi
else
display --to SCREEN+LOG --type PLAIN --color RED --result WARNING --screen-indent 4 NETWORK_PROMISC_CHECK
display --to LOG --type WARNING NETWORK_PROMISC_NO_IFCONF_IP
fi
else
display --to LOG --type INFO --nl USER_DISABLED_TEST promisc
fi
#
# For the packet capturing check, we must first see if we
# are able to run the test. We let the user know if the test
# was disabled, or if the lsof command is not present.
#
if `check_test packet_cap_apps`; then
display --to LOG --type INFO --nl STARTING_TEST packet_cap_apps
else
display --to LOG --type INFO --nl USER_DISABLED_TEST packet_cap_apps
return
fi
if [ $LINUXOS -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --color YELLOW --result SKIPPED --log-indent 2 --screen-indent 4 NETWORK_PACKET_CAP_CHECK
display --to LOG --type INFO TEST_SKIPPED_OS 'packet_cap_apps' '/proc/net/packet required.'
return
elif [ ! -f "/proc/net/packet" ]; then
display --to SCREEN+LOG --type PLAIN --color RED --result WARNING --log-indent 2 --screen-indent 4 NETWORK_PACKET_CAP_CHECK
display --to LOG --type WARNING NETWORK_PACKET_CAP_CHECK_NO_FILE '/proc/net/packet'
return
elif [ -z "${LSOF_CMD}" ]; then
display --to SCREEN+LOG --type PLAIN --color YELLOW --result SKIPPED --log-indent 2 --screen-indent 4 NETWORK_PACKET_CAP_CHECK
display --to LOG --type INFO NOT_FOUND_CMD 'lsof'
return
fi
#
# Now run the test.
#
FOUND=0
WHITEPROC=""
BLACKPROC=""
LIBPCAPRES=`egrep -v '(^sk | 888e )' /proc/net/packet | head ${HEAD_OPT}1`
if [ -n "${LIBPCAPRES}" ]; then
ALLOWPROCLISTENERS=""
if [ -n "${ALLOWPROCLIST_OPT}" ]; then
ALLOWPROCLISTENERS=`expand_paths ALLOWPROCLIST_OPT`
fi
INODE_LIST=""
for INODE in `egrep -v '(^sk | 888e )' /proc/net/packet | awk '{ print $9 }'`; do
INODE_LIST="${INODE_LIST}|$INODE"
done
INODE_LIST=`echo "${INODE_LIST}" | sed -e 's/^|//'`
test -z "${INODE_LIST}" && INODE_LIST="RKHunterPktCapture"
for PID in `${LSOF_CMD} -lMnPw -d 1-20 | egrep "[ ](pack[ ]+(${INODE_LIST})|sock[ ]+[^ ]+[ ]+[^ ]+[ ]+(${INODE_LIST}))[ ]" | awk '{ print $2 }'`; do
NAME=""
if [ -h "/proc/$PID/exe" -a $HAVE_READLINK -eq 1 ]; then
NAME=`${READLINK_CMD} -f "/proc/$PID/exe" | cut -d' ' -f1`
elif [ -f "/proc/$PID/status" ]; then
NAME=`grep '^Name:.' /proc/$PID/status | sed -e 's/^Name:.//'`
fi
test -z "${NAME}" && continue
FNAMEGREP=`echo "${NAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -n "`echo \"${ALLOWPROCLISTENERS}\" | grep \"^${FNAMEGREP}$\"`" ]; then
if [ -z "`echo \"${WHITEPROC}\" | grep \"^${FNAMEGREP}$\"`" ]; then
WHITEPROC="${WHITEPROC}
${NAME}"
fi
else
FOUND=1
BLACKPROC="${BLACKPROC}
${PID}:${NAME}"
fi
done
fi
#
# Now display the results.
#
if [ $FOUND -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --color GREEN --result NONE_FOUND --log-indent 2 --screen-indent 4 NETWORK_PACKET_CAP_CHECK
else
display --to SCREEN+LOG --type PLAIN --color RED --result WARNING --log-indent 2 --screen-indent 4 NETWORK_PACKET_CAP_CHECK
IFS=$IFSNL
for RKHTMPVAR in ${BLACKPROC}; do
test -z "${RKHTMPVAR}" && continue
PID=`echo "${RKHTMPVAR}" | cut -d: -f1`
NAME=`echo "${RKHTMPVAR}" | cut -d: -f2-`
display --to LOG --type WARNING NETWORK_PACKET_CAP_FOUND "`name2text \"${NAME}\"`" "${PID}"
done
IFS=$RKHIFS
fi
IFS=$IFSNL
for NAME in ${WHITEPROC}; do
test -z "${NAME}" && continue
display --to LOG --type INFO NETWORK_PACKET_CAP_WL "`name2text \"${NAME}\"`"
done
IFS=$RKHIFS
return
}
do_network_checks() {
#
# This function carries out some network checks. This consists
# of port checks, and some interface checks.
#
if `check_test network`; then
display --to LOG --type INFO --screen-nl --nl STARTING_TEST network
display --to SCREEN+LOG --type PLAIN --color YELLOW CHECK_NETWORK
else
display --to LOG --type INFO --nl USER_DISABLED_TEST network
return
fi
do_network_port_checks
do_network_hidden_port_checks
do_network_interface_checks
return
}
do_system_startup_file_checks() {
#
# This function carries out checks on the system startup files.
#
if `check_test startup_files`; then
display --to LOG --type INFO --screen-nl --nl STARTING_TEST startup_files
display --to SCREEN+LOG --type PLAIN --screen-indent 2 STARTUP_FILES_START
else
display --to LOG --type INFO --nl USER_DISABLED_TEST startup_files
return
fi
#
# First we check that the local host name has been set.
#
if [ -n "${HOST_NAME}" ]; then
display --to SCREEN+LOG --type PLAIN --color GREEN --result FOUND --log-indent 2 --screen-indent 4 STARTUP_HOSTNAME
else
display --to SCREEN+LOG --type PLAIN --color RED --result WARNING --log-indent 2 --screen-indent 4 STARTUP_HOSTNAME
display --to LOG --type WARNING STARTUP_NO_HOSTNAME
fi
#
# Check that the startup file malware checks are to be done.
#
if `check_test startup_malware`; then
display --to LOG --type INFO --nl STARTING_TEST startup_malware
else
display --to LOG --type INFO --nl USER_DISABLED_TEST startup_malware
return
fi
#
# First check to see that we can run the test.
#
if [ "${STARTUP_PATHS}" = "NONE" ]; then
display --to SCREEN+LOG --type PLAIN --color GREEN --result SKIPPED --log-indent 2 --screen-indent 4 STARTUP_CHECK_FILES_EXIST
display --to LOG --type INFO STARTUP_NONE_GIVEN
return
fi
#
# Now get and check that the system startup files are okay.
#
get_rc_paths
if [ -n "${RC_PATHS}" ]; then
display --to SCREEN+LOG --type PLAIN --color GREEN --result FOUND --log-indent 2 --screen-indent 4 STARTUP_CHECK_FILES_EXIST
else
display --to SCREEN+LOG --type PLAIN --color RED --result WARNING --log-indent 2 --screen-indent 4 STARTUP_CHECK_FILES_EXIST
display --to LOG --type WARNING STARTUP_CHECK_NO_RC_FILES
return
fi
#
# Next we check all the startup files for any suspicious
# strings in them.
#
FOUND=0
FOUNDSTRINGS=""
#
# Since we are going to be checking a lot of files
# for strings that are static, we may as well do
# some pre-processing of the string, and then we
# only need to spend time if a string is found.
#
RCSTRINGS=""
IFS=$IFSNL
for RKHTMPVAR in ${RCLOCAL_STRINGS}; do
RKHTMPVAR=`echo ${RKHTMPVAR} | sed -e 's/^[ ]*//'`
STRING=`echo ${RKHTMPVAR} | cut -d: -f1 | sed -e 's/\./\\\./g'`
INFO=`echo ${RKHTMPVAR} | cut -d: -f2`
RCSTRINGS="${RCSTRINGS}
${STRING}:${INFO}"
ROOTKIT_COUNT=`expr ${ROOTKIT_COUNT} + 1`
done
IFS=$RKHIFS
RCSTRINGS=`echo "${RCSTRINGS}" | sed -e '/^$/d'`
for FNAME in ${RC_PATHS}; do
IFS=$IFSNL
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
for STR in ${RCSTRINGS}; do
STRING=`echo ${STR} | cut -d: -f1`
RKHTMPVAR=`grep "${STRING}" "${FNAME}"`
if [ -n "${RKHTMPVAR}" ]; then
test -z "`echo \"${RKHTMPVAR}\" | egrep -v '^[ ]*#'`" && continue
if [ -n "`echo \"${RTKT_FILE_WHITELIST}\" | grep \"^${FNAMEGREP}:${STRING}$\"`" ]; then
STRING=`echo ${STRING} | sed -e 's/\\\//g'`
display --to LOG --type INFO FILE_PROP_WL_STR "`name2text \"${FNAME}\"`" "${STRING}" 'startup_malware'
elif [ -n "`echo \"${RTKT_FILE_WHITELIST}\" | grep \"^${FNAMEGREP}$\"`" -a -z "`echo \"${RTKT_FILE_WHITELIST}\" | grep \"^${FNAMEGREP}:$\"`" ]; then
display --to LOG --type INFO FILE_PROP_WL "`name2text \"${FNAME}\"`" 'startup_malware'
else
FOUND=1
STRING=`echo ${STRING} | sed -e 's/\\\//g'`
INFO=`echo ${STR} | cut -d: -f2`
FOUNDSTRINGS="${FOUNDSTRINGS}
${FNAME}:${STRING}:${INFO}"
fi
fi
done
IFS=$RKHIFS
done
#
# Now display the results.
#
if [ $FOUND -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --color GREEN --result NONE_FOUND --log-indent 2 --screen-indent 4 STARTUP_CHECK_FILES_MALWARE
else
display --to SCREEN+LOG --type PLAIN --color RED --result WARNING --log-indent 2 --screen-indent 4 STARTUP_CHECK_FILES_MALWARE
IFS=$IFSNL
FOUNDSTRINGS=`echo "${FOUNDSTRINGS}" | sed -e '/^$/d'`
for RKHTMPVAR in ${FOUNDSTRINGS}; do
FNAME=`echo "${RKHTMPVAR}" | cut -d: -f1`
STRING=`echo "${RKHTMPVAR}" | cut -d: -f2`
INFO=`echo "${RKHTMPVAR}" | cut -d: -f3`
ROOTKIT_FAILED_COUNT=`expr ${ROOTKIT_FAILED_COUNT} + 1`
ROOTKIT_FAILED_NAMES="${ROOTKIT_FAILED_NAMES}${INFO}, "
display --to LOG --type WARNING ROOTKIT_POSS_STRINGS_FOUND "${STRING}" "`name2text \"${FNAME}\"`" "${INFO}"
done
IFS=$RKHIFS
fi
return
}
pwdgrp_changes() {
#
# This function checks the changes made to the passwd and group files.
#
FNAME=$1
LINES=$2
SEEN_IDS=""
IFS=$IFSNL
for LINE in ${LINES}; do
#
# First we need to check if we have already dealt with
# this id. If we have, then just get the next line.
#
PWDGRPID=`echo "${LINE}" | cut -d: -f1 | cut -c3-`
IDGREP=`echo "${PWDGRPID}" | sed -e 's/\./\\\./g'`
RKHTMPVAR=`echo "${SEEN_IDS}" | grep " ${IDGREP} "`
test -n "${RKHTMPVAR}" && continue
#
# This id hasn't been seen before, so we record it.
#
SEEN_IDS="${SEEN_IDS} ${PWDGRPID} "
#
# Next we see if the id has just been added or removed.
# To do this we simply see if it appears more than once.
#
RKHTMPVAR=`echo "${LINES}" | grep "^> ${IDGREP}:"`
RKHTMPVAR2=`echo "${LINES}" | grep "^< ${IDGREP}:"`
if [ \( -n "${RKHTMPVAR}" -a -z "${RKHTMPVAR2}" \) -o \( -z "${RKHTMPVAR}" -a -n "${RKHTMPVAR2}" \) ]; then
if [ -n "${RKHTMPVAR}" ]; then
if [ "${FNAME}" = "passwd" ]; then
display --to LOG --type WARNING --log-indent 4 PWD_CHANGES_IDREM "${PWDGRPID}"
else
display --to LOG --type WARNING --log-indent 4 GROUP_CHANGES_IDREM "${PWDGRPID}"
fi
else
if [ "${FNAME}" = "passwd" ]; then
display --to LOG --type WARNING --log-indent 4 PWD_CHANGES_IDADD "${PWDGRPID}"
else
display --to LOG --type WARNING --log-indent 4 GROUP_CHANGES_IDADD "${PWDGRPID}"
fi
fi
continue
fi
#
# The id has changed in some way. We now need to
# go through the fields and see what has changed.
#
FIELD_IDX=1
OLD_LINE=`echo "${RKHTMPVAR}" | cut -d: -f2-`
NEW_LINE=`echo "${RKHTMPVAR2}" | cut -d: -f2-`
STR=${OLD_LINE}
if [ "${FNAME}" = "passwd" ]; then
display --to LOG --type WARNING PWD_CHANGES_FOUND "${PWDGRPID}"
else
display --to LOG --type WARNING GROUP_CHANGES_FOUND "${PWDGRPID}"
fi
while test -n "${STR}"; do
OLD_FIELD=`echo "${OLD_LINE}" | cut -d: -f$FIELD_IDX`
NEW_FIELD=`echo "${NEW_LINE}" | cut -d: -f$FIELD_IDX`
if [ "${OLD_FIELD}" != "${NEW_FIELD}" ]; then
if [ "${FNAME}" = "passwd" ]; then
case $FIELD_IDX in
1)
display --to LOG --type PLAIN --log-indent 9 PWD_CHANGES_PWD "${OLD_FIELD}" "${NEW_FIELD}"
;;
2)
display --to LOG --type PLAIN --log-indent 9 PWD_CHANGES_UID "${OLD_FIELD}" "${NEW_FIELD}"
;;
3)
display --to LOG --type PLAIN --log-indent 9 PWD_CHANGES_GID "${OLD_FIELD}" "${NEW_FIELD}"
;;
4)
display --to LOG --type PLAIN --log-indent 9 PWD_CHANGES_COMM "${OLD_FIELD}" "${NEW_FIELD}"
;;
5)
display --to LOG --type PLAIN --log-indent 9 PWD_CHANGES_HOME "${OLD_FIELD}" "${NEW_FIELD}"
;;
6)
display --to LOG --type PLAIN --log-indent 9 PWD_CHANGES_SHL "${OLD_FIELD}" "${NEW_FIELD}"
;;
*)
display --to LOG --type PLAIN --log-indent 9 PWDGRP_CHANGES_UNK "${FNAME}" "${OLD_FIELD}" "${NEW_FIELD}"
;;
esac
else
case $FIELD_IDX in
1)
display --to LOG --type PLAIN --log-indent 9 GROUP_CHANGES_PWD "${OLD_FIELD}" "${NEW_FIELD}"
;;
2)
display --to LOG --type PLAIN --log-indent 9 GROUP_CHANGES_GID "${OLD_FIELD}" "${NEW_FIELD}"
;;
3)
OLD_GRPUSRS=" `echo ${OLD_FIELD} | tr ',' ' '` "
NEW_GRPUSRS=" `echo ${NEW_FIELD} | tr ',' ' '` "
IFS=$RKHIFS
for GRPUSR in ${OLD_GRPUSRS} ${NEW_GRPUSRS}; do
RKHTMPVAR=`echo ${GRPUSR} | sed -e 's/\./\\\./g'`
RKHTMPVAR2=`echo "${OLD_GRPUSRS}" | grep " ${RKHTMPVAR} "`
RKHTMPVAR3=`echo "${NEW_GRPUSRS}" | grep " ${RKHTMPVAR} "`
if [ -n "${RKHTMPVAR2}" -a -z "${RKHTMPVAR3}" ]; then
display --to LOG --type PLAIN --log-indent 9 GROUP_CHANGES_GRPREM "${GRPUSR}"
elif [ -z "${RKHTMPVAR2}" -a -n "${RKHTMPVAR3}" ]; then
display --to LOG --type PLAIN --log-indent 9 GROUP_CHANGES_GRPADD "${GRPUSR}"
fi
done
IFS=$IFSNL
;;
*)
display --to LOG --type PLAIN --log-indent 9 PWDGRP_CHANGES_UNK "${FNAME}" "${OLD_FIELD}" "${NEW_FIELD}"
;;
esac
fi
fi
FIELD_IDX=`expr $FIELD_IDX + 1`
RKHTMPVAR=`echo "${STR}" | cut -d: -f2-`
#
# For the group file the last field may be
# empty, so we need to cater for this.
#
if [ -z "${RKHTMPVAR}" ]; then
if [ \( "${FNAME}" = "passwd" -a $FIELD_IDX -eq 6 \) -o \( "${FNAME}" = "group" -a $FIELD_IDX -eq 3 \) ]; then
STR=""
RKHTMPVAR="x"
fi
fi
test "${RKHTMPVAR}" = "${STR}" && STR="" || STR=${RKHTMPVAR}
done
done
IFS=$RKHIFS
return
}
do_group_accounts_check() {
#
# This function carries out checks on the /etc/passwd and
# /etc/group files.
#
if `check_test group_accounts`; then
display --to LOG --type INFO --screen-nl --nl STARTING_TEST group_accounts
display --to SCREEN+LOG --type PLAIN --screen-indent 2 ACCOUNTS_START
else
display --to LOG --type INFO --nl USER_DISABLED_TEST group_accounts
return
fi
#
# First check that /etc/passwd exists.
#
if [ -s "/etc/passwd" ]; then
display --to SCREEN+LOG --type PLAIN --color GREEN --result FOUND --log-indent 2 --screen-indent 4 ACCOUNTS_PWD_FILE_CHECK
display --to LOG --type INFO ACCOUNTS_FOUND_PWD_FILE '/etc/passwd'
else
display --to SCREEN+LOG --type PLAIN --color RED --result WARNING --log-indent 2 --screen-indent 4 ACCOUNTS_PWD_FILE_CHECK
display --to LOG --type WARNING ACCOUNTS_NO_PWD_FILE '/etc/passwd'
fi
#
# Next, check for root equivalent accounts. These will have
# a UID of zero.
#
if [ -s "/etc/passwd" ]; then
UID_LIST=""
RKHTMPVAR2=""
if [ $MACOSX -eq 1 ]; then
DSCL_CMD=`find_cmd dscl`
if [ -n "${DSCL_CMD}" ]; then
display --to LOG --type INFO FOUND_CMD 'dscl' "${DSCL_CMD}"
RKHTMPVAR2=`${DSCL_CMD} . search /Users uid 0 | egrep '^[^ )]' | cut -d' ' -f1`
else
display --to LOG --type INFO NOT_FOUND_CMD 'dscl'
fi
fi
IFS=$IFSNL
for RKHTMPVAR in `grep '^[^:]*:[^:]*:0:' /etc/passwd | cut -d: -f1` ${RKHTMPVAR2}; do
test -z "${RKHTMPVAR}" && continue
test "${RKHTMPVAR}" = "root" && continue
RKHUSERID=`echo "${RKHTMPVAR}" | sed -e 's/\./\\\./g'`
#
# We will ignore any whitelisted UID 0 accounts.
#
if [ -z "`echo \"${UID0_WHITELIST}\" | grep \" ${RKHUSERID} \"`" ]; then
UID_LIST="${UID_LIST}
${RKHTMPVAR}"
else
display --to LOG --type INFO ACCOUNTS_UID0_WL "${RKHTMPVAR}"
fi
done
IFS=$RKHIFS
#
# Now display the results.
#
if [ -z "${UID_LIST}" ]; then
display --to SCREEN+LOG --type PLAIN --result NONE_FOUND --color GREEN --log-indent 2 --screen-indent 4 ACCOUNTS_UID0
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 ACCOUNTS_UID0
IFS=$IFSNL
for RKHTMPVAR in ${UID_LIST}; do
test -z "${RKHTMPVAR}" && continue
display --to LOG --type WARNING ACCOUNTS_UID0_FOUND "${RKHTMPVAR}"
done
IFS=$RKHIFS
fi
else
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --log-indent 2 --screen-indent 4 ACCOUNTS_UID0
display --to LOG --type INFO ACCOUNTS_NO_PWD_FILE '/etc/passwd'
fi
#
# Now check for any passwordless accounts. We do this in two steps.
# The first is to check the shadow file, and for TCB shadow files we
# have to loop through all the shadow files in the /etc/tcb directory.
# Then we check the /etc/passwd file for any passwordless accounts.
# Finally we display the overall result. We ignore any whitelisted
# passwordless accounts.
#
WL_SEEN=""
PWD_PWDLESS_LIST=""
SHAD_PWDLESS_LIST=""
#
# Check for passwordless accounts in the shadow file(s).
#
if [ -n "${SHADOW_FILE}" -o $HAVE_TCB_SHADOW -eq 1 ]; then
if [ -n "${SHADOW_FILE}" ]; then
display --to LOG --type INFO ACCOUNTS_SHADOW_FILE "${SHADOW_FILE}"
else
display --to LOG --type INFO ACCOUNTS_SHADOW_TCB '/etc/tcb'
fi
#
# We have do a bit of a kludge here. We need a loop in order to
# cater for TCB shadow files in /etc/tcb. But at the same time
# we only want to execute the loop once for non-TCB systems. To
# do this we loop through either /etc or /etc/tcb. However, for
# /etc we only execute the loop once because the grep statement
# will have the exact shadow filename in SHADOW_FILE. For TCB
# systems, SHADOW_FILE is set for each individual shadow file as
# it pass round the loop.
#
if [ $HAVE_TCB_SHADOW -eq 1 ]; then
RKHTMPVAR2="/etc/tcb"
else
RKHTMPVAR2="/etc"
fi
IFS=$IFSNL
for DIR in ${RKHTMPVAR2}/*; do
if [ $HAVE_TCB_SHADOW -eq 1 ]; then
if [ -f "${DIR}/shadow" ]; then
SHADOW_FILE="${DIR}/shadow"
else
continue
fi
fi
for RKHTMPVAR in `grep '^[^:]*::' "${SHADOW_FILE}" | cut -d: -f1`; do
# Ignore any NIS/YP entries
test "${RKHTMPVAR}" = "+" && continue
RKHUSERID=`echo "${RKHTMPVAR}" | sed -e 's/\./\\\./g'`
if [ -z "`echo \"${PWD_WHITELIST}\" | grep \" ${RKHUSERID} \"`" ]; then
SHAD_PWDLESS_LIST="${SHAD_PWDLESS_LIST}
${RKHTMPVAR}"
test $HAVE_TCB_SHADOW -eq 1 && SHAD_PWDLESS_LIST="${SHAD_PWDLESS_LIST} (${SHADOW_FILE})"
else
WL_SEEN="${WL_SEEN} ${RKHTMPVAR} "
display --to LOG --type INFO ACCOUNTS_PWDLESS_WL "${RKHTMPVAR}"
fi
done
test $HAVE_TCB_SHADOW -eq 0 && break
done
IFS=$RKHIFS
else
#
# No shadow file found.
#
SHAD_PWDLESS_LIST="RKH:No shadow file"
fi
#
# Check for passwordless accounts in /etc/passwd.
#
if [ -s "/etc/passwd" ]; then
IFS=$IFSNL
for RKHTMPVAR in `grep '^[^:]*::' /etc/passwd | cut -d: -f1`; do
# Ignore any NIS/YP entries
test "${RKHTMPVAR}" = "+" && continue
RKHUSERID=`echo "${RKHTMPVAR}" | sed -e 's/\./\\\./g'`
if [ -z "`echo \"${PWD_WHITELIST}\" | grep \" ${RKHUSERID} \"`" ]; then
PWD_PWDLESS_LIST="${PWD_PWDLESS_LIST}
${RKHTMPVAR}"
elif [ -z "`echo \"${WL_SEEN}\" | grep \" ${RKHUSERID} \"`" ]; then
display --to LOG --type INFO ACCOUNTS_PWDLESS_WL "${RKHTMPVAR}"
fi
done
IFS=$RKHIFS
fi
#
# Now display the results.
#
if [ -z "${SHAD_PWDLESS_LIST}" -a -z "${PWD_PWDLESS_LIST}" ]; then
display --to SCREEN+LOG --type PLAIN --color GREEN --result NONE_FOUND --log-indent 2 --screen-indent 4 ACCOUNTS_PWDLESS
else
display --to SCREEN+LOG --type PLAIN --color RED --result WARNING --log-indent 2 --screen-indent 4 ACCOUNTS_PWDLESS
#
# Log the shadow file results.
#
if [ "${SHAD_PWDLESS_LIST}" = "RKH:No shadow file" ]; then
display --to LOG --type WARNING ACCOUNTS_NO_SHADOW_FILE
else
IFS=$IFSNL
for RKHTMPVAR in ${SHAD_PWDLESS_LIST}; do
test -z "${RKHTMPVAR}" && continue
display --to LOG --type WARNING ACCOUNTS_PWDLESS_FOUND 'shadow' "${RKHTMPVAR}"
done
fi
#
# Log the passwd file results.
#
IFS=$IFSNL
for RKHTMPVAR in ${PWD_PWDLESS_LIST}; do
test -z "${RKHTMPVAR}" && continue
display --to LOG --type WARNING ACCOUNTS_PWDLESS_FOUND 'passwd' "${RKHTMPVAR}"
done
IFS=$RKHIFS
fi
#
# Now we check for any changes that have occurred to the passwd
# file since rkhunter was last run.
#
DIFF_CMD=`find_cmd diff`
if `check_test passwd_changes`; then
RKHTMPVAR=0
display --to LOG --type INFO --nl STARTING_TEST passwd_changes
else
RKHTMPVAR=1
display --to LOG --type INFO --nl USER_DISABLED_TEST passwd_changes
fi
if [ $RKHTMPVAR -eq 1 ]; then
:
elif [ ! -f "/etc/passwd" ]; then
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --log-indent 2 --screen-indent 4 PASSWD_CHANGES
display --to LOG --type INFO ACCOUNTS_NO_PWD_FILE '/etc/passwd'
elif [ -z "${DIFF_CMD}" ]; then
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --log-indent 2 --screen-indent 4 PASSWD_CHANGES
display --to LOG --type INFO NOT_FOUND_CMD 'diff'
cp -f -p /etc/passwd "${RKHTMPDIR}/passwd"
elif [ ! -f "${RKHTMPDIR}/passwd" ]; then
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 PASSWD_CHANGES
display --to LOG --type WARNING PASSWD_CHANGES_NO_TMP
cp -f -p /etc/passwd "${RKHTMPDIR}/passwd"
else
DIFFS=`${DIFF_CMD} /etc/passwd "${RKHTMPDIR}/passwd" 2>/dev/null | grep '^[<>]'`
if [ -z "${DIFFS}" ]; then
display --to SCREEN+LOG --type PLAIN --color GREEN --result NONE_FOUND --log-indent 2 --screen-indent 4 PASSWD_CHANGES
else
display --to SCREEN+LOG --type PLAIN --color RED --result WARNING --log-indent 2 --screen-indent 4 PASSWD_CHANGES
pwdgrp_changes "passwd" "${DIFFS}"
#
# Finally, move the current copy of the passwd file out
# of the way, and take a new copy of the passwd file.
# This allows the user to look back to see what the
# last changes were, even if RKH is run again.
#
mv -f "${RKHTMPDIR}/passwd" "${RKHTMPDIR}/passwd.old" >/dev/null 2>&1
cp -f -p /etc/passwd "${RKHTMPDIR}/passwd"
fi
fi
#
# Next check for any changes that have occurred to the group
# file since rkhunter was last run.
#
if `check_test group_changes`; then
RKHTMPVAR=0
display --to LOG --type INFO --nl STARTING_TEST group_changes
else
RKHTMPVAR=1
display --to LOG --type INFO --nl USER_DISABLED_TEST group_changes
fi
if [ $RKHTMPVAR -eq 1 ]; then
:
elif [ ! -f "/etc/group" ]; then
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --log-indent 2 --screen-indent 4 GROUP_CHANGES
display --to LOG --type WARNING GROUP_CHANGES_NO_FILE '/etc/group'
elif [ -z "${DIFF_CMD}" ]; then
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --log-indent 2 --screen-indent 4 GROUP_CHANGES
display --to LOG --type INFO NOT_FOUND_CMD 'diff'
cp -f -p /etc/group "${RKHTMPDIR}/group"
elif [ ! -f "${RKHTMPDIR}/group" ]; then
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 GROUP_CHANGES
display --to LOG --type WARNING GROUP_CHANGES_NO_TMP
cp -f -p /etc/group "${RKHTMPDIR}/group"
else
DIFFS=`${DIFF_CMD} /etc/group "${RKHTMPDIR}/group" 2>/dev/null | grep '^[<>]'`
if [ -z "${DIFFS}" ]; then
display --to SCREEN+LOG --type PLAIN --color GREEN --result NONE_FOUND --log-indent 2 --screen-indent 4 GROUP_CHANGES
else
display --to SCREEN+LOG --type PLAIN --color RED --result WARNING --log-indent 2 --screen-indent 4 GROUP_CHANGES
pwdgrp_changes "group" "${DIFFS}"
#
# Finally, move the current copy of the group file out
# of the way, and take a new copy of the group file.
# This allows the user to look back to see what the
# last changes were, even if RKH is run again.
#
mv -f "${RKHTMPDIR}/group" "${RKHTMPDIR}/group.old" >/dev/null 2>&1
cp -f -p /etc/group "${RKHTMPDIR}/group"
fi
fi
#
# Finally we do a check on the root account shell history files.
# We check for bash, Korn, C-shell and zsh history files.
#
FOUND=0
FOUNDFILES=""
if [ -f "/root/.bash_history" ]; then
FOUND=1
if [ -h "/root/.bash_history" ]; then
FOUNDFILES="${FOUNDFILES} bash:/root/.bash_history"
fi
fi
if [ -f "/root/.sh_history" ]; then
FOUND=1
if [ -h "/root/.sh_history" ]; then
FOUNDFILES="${FOUNDFILES} Korn:/root/.sh_history"
fi
fi
if [ -f "/root/.history" ]; then
FOUND=1
if [ -h "/root/.history" ]; then
FOUNDFILES="${FOUNDFILES} C-shell:/root/.history"
fi
fi
if [ -f "/root/.zhistory" ]; then
FOUND=1
if [ -h "/root/.zhistory" ]; then
FOUNDFILES="${FOUNDFILES} zsh:/root/.zhistory"
fi
fi
#
# Now display the results.
#
if [ -z "${FOUNDFILES}" ]; then
test $FOUND -eq 1 && RKHTMPVAR="OK" || RKHTMPVAR="NONE_FOUND"
display --to SCREEN+LOG --type PLAIN --color GREEN --result ${RKHTMPVAR} --log-indent 2 --screen-indent 4 HISTORY_CHECK
else
display --to SCREEN+LOG --type PLAIN --color RED --result WARNING --log-indent 2 --screen-indent 4 HISTORY_CHECK
for RKHTMPVAR in ${FOUNDFILES}; do
SHELLNAME=`echo "${RKHTMPVAR}" | cut -d: -f1`
FILENAME=`echo "${RKHTMPVAR}" | cut -d: -f2`
display --to LOG --type WARNING HISTORY_CHECK_FOUND "`name2text \"${SHELLNAME}\"`" "`name2text \"${FILENAME}\"`"
done
fi
return
}
do_system_config_files_check() {
#
# This function carries out checks on some of the system
# software configurations. At present this checks the SSH
# and system logging configurations.
#
if `check_test system_configs`; then
display --to LOG --type INFO --screen-nl --nl STARTING_TEST system_configs
display --to SCREEN+LOG --type PLAIN --screen-indent 2 SYSTEM_CONFIGS_START
else
display --to LOG --type INFO --nl USER_DISABLED_TEST system_configs
return
fi
#
# First find out where the SSH configuration file is located.
#
SSH_CONFIG_FILE=""
if [ -n "${SSH_CONFIG_DIR}" ]; then
RKHTMPVAR="${SSH_CONFIG_DIR}"
else
RKHTMPVAR="/etc /etc/ssh /usr/local/etc /usr/local/etc/ssh"
fi
for DIR in ${RKHTMPVAR}; do
if [ -f "${DIR}/sshd_config" ]; then
SSH_CONFIG_FILE="${DIR}/sshd_config"
break
fi
done
if [ -n "${SSH_CONFIG_FILE}" ]; then
display --to SCREEN+LOG --type PLAIN --result FOUND --color GREEN --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_FILE_SSH
display --to LOG --type INFO SYSTEM_CONFIGS_FILE_FOUND 'an' 'SSH' "${SSH_CONFIG_FILE}"
display --to LOG --type INFO CONFIG_SSH_ROOT "${ALLOW_SSH_ROOT_USER}"
display --to LOG --type INFO CONFIG_SSH_PROTV1 $ALLOW_SSH_PROT_V1
#
# Now we check some of the configuration options.
#
# First we check for allowed root access.
#
RKHTMPVAR=`grep -i '^[ ]*PermitRootLogin[ =]' "${SSH_CONFIG_FILE}" | tail ${TAIL_OPT}1`
if [ -n "${RKHTMPVAR}" ]; then
#
# Get the value that has been set.
#
RKHTMPVAR2=`echo ${RKHTMPVAR} | sed -e 's/^[^ =]*[ ]*=*[ ]*\([^ #]*\).*$/\1/' | tr '[:upper:]' '[:lower:]'`
if [ "${RKHTMPVAR2}" = "${ALLOW_SSH_ROOT_USER}" ]; then
test "${RKHTMPVAR2}" = "no" && RKHTMPVAR="NOT_ALLOWED" || RKHTMPVAR="ALLOWED"
display --to SCREEN+LOG --type PLAIN --result ${RKHTMPVAR} --color GREEN --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_SSH_ROOT
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_SSH_ROOT
display --to LOG --type WARNING SYSTEM_CONFIGS_SSH_ROOT_FOUND
display --to LOG --type PLAIN --log-indent 9 SYSTEM_CONFIGS_SSH_ROOT_FOUND1 "${RKHTMPVAR2}"
display --to LOG --type PLAIN --log-indent 9 SYSTEM_CONFIGS_SSH_ROOT_FOUND2 "${ALLOW_SSH_ROOT_USER}"
fi
elif [ "${ALLOW_SSH_ROOT_USER}" = "unset" ]; then
display --to SCREEN+LOG --type PLAIN --result UNSET --color GREEN --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_SSH_ROOT
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_SSH_ROOT
display --to LOG --type WARNING SYSTEM_CONFIGS_SSH_ROOT_NOTFOUND
fi
#
# Next we check to see if protocol version 1 is allowed.
#
RKHTMPVAR=`grep -i '^[ ]*Protocol[ =]' "${SSH_CONFIG_FILE}" | tail ${TAIL_OPT}1`
if [ -n "${RKHTMPVAR}" ]; then
#
# See if the set protocol versions includes '1'.
#
RKHTMPVAR2=`echo ${RKHTMPVAR} | sed -e 's/^[^ =]*[ ]*=*[ ]*\([^ #]*\).*$/\1/'`
RKHTMPVAR3=`echo "${RKHTMPVAR2}" | grep '1'`
if [ -z "${RKHTMPVAR3}" -a $ALLOW_SSH_PROT_V1 -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --result NOT_ALLOWED --color GREEN --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_SSH_PROTO
elif [ -n "${RKHTMPVAR3}" -a $ALLOW_SSH_PROT_V1 -eq 1 ]; then
display --to SCREEN+LOG --type PLAIN --result ALLOWED --color GREEN --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_SSH_PROTO
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_SSH_PROTO
display --to LOG --type WARNING SYSTEM_CONFIGS_SSH_ROOT_FOUND
display --to LOG --type PLAIN --log-indent 9 SYSTEM_CONFIGS_SSH_PROTO_DIFF1 "${RKHTMPVAR2}"
display --to LOG --type PLAIN --log-indent 9 SYSTEM_CONFIGS_SSH_PROTO_DIFF2 "${ALLOW_SSH_PROT_V1}"
fi
elif [ $ALLOW_SSH_PROT_V1 -eq 2 ]; then
display --to SCREEN+LOG --type PLAIN --result UNSET --color GREEN --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_SSH_PROTO
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_SSH_PROTO
display --to LOG --type WARNING SYSTEM_CONFIGS_SSH_PROTO_NOTFOUND
fi
else
display --to SCREEN+LOG --type PLAIN --result NOT_FOUND --color GREEN --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_FILE_SSH
fi
#
# Next we find out if a system logging daemon is running.
#
TITLE_SHOWN=0
SYSLOG_SEEN=0; SYSTEMD_SEEN=0
METALOG_SEEN=0; SOCKLOG_SEEN=0
if [ -n "${PS_CMD}" ]; then
PS_ARGS="ax"
test $SUNOS -eq 1 -o $IRIXOS -eq 1 && PS_ARGS="-ef"
RKHTMPVAR=`${PS_CMD} ${PS_ARGS} | egrep '(syslogd|syslog-ng)( |$)' | grep -v 'egrep'`
if [ -n "${RKHTMPVAR}" ]; then
SYSLOG_SEEN=1
test $TITLE_SHOWN -eq 0 && display --to SCREEN+LOG --type PLAIN --result FOUND --color GREEN --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_SYSLOG
if [ -n "`echo \"${RKHTMPVAR}\" | grep 'rsyslog'`" ]; then
display --to LOG --type INFO --log-indent 2 SYSTEM_CONFIGS_SYSLOG_DAEMON 'rsyslog'
elif [ -n "`echo \"${RKHTMPVAR}\" | grep 'syslog-ng'`" ]; then
display --to LOG --type INFO --log-indent 2 SYSTEM_CONFIGS_SYSLOG_DAEMON 'syslog-ng'
else
display --to LOG --type INFO --log-indent 2 SYSTEM_CONFIGS_SYSLOG_DAEMON 'syslog'
fi
TITLE_SHOWN=1
fi
RKHTMPVAR=`${PS_CMD} ${PS_ARGS} | egrep 'systemd-journald( |$)' | grep -v 'egrep'`
if [ -n "${RKHTMPVAR}" ]; then
SYSTEMD_SEEN=1
test $TITLE_SHOWN -eq 0 && display --to SCREEN+LOG --type PLAIN --result FOUND --color GREEN --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_SYSLOG
display --to LOG --type INFO --log-indent 2 SYSTEM_CONFIGS_SYSLOG_DAEMON 'systemd-journald'
TITLE_SHOWN=1
fi
RKHTMPVAR=`${PS_CMD} ${PS_ARGS} | egrep 'metalog( |$)' | grep -v 'egrep'`
if [ -n "${RKHTMPVAR}" ]; then
METALOG_SEEN=1
test $TITLE_SHOWN -eq 0 && display --to SCREEN+LOG --type PLAIN --result FOUND --color GREEN --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_SYSLOG
display --to LOG --type INFO --log-indent 2 SYSTEM_CONFIGS_SYSLOG_DAEMON 'metalog'
TITLE_SHOWN=1
fi
RKHTMPVAR=`${PS_CMD} ${PS_ARGS} | egrep 'socklog( |$)' | grep -v 'egrep'`
if [ -n "${RKHTMPVAR}" ]; then
SOCKLOG_SEEN=1
test $TITLE_SHOWN -eq 0 && display --to SCREEN+LOG --type PLAIN --result FOUND --color GREEN --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_SYSLOG
display --to LOG --type INFO --log-indent 2 SYSTEM_CONFIGS_SYSLOG_DAEMON 'socklog'
TITLE_SHOWN=1
fi
if [ $TITLE_SHOWN -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_SYSLOG
display --to LOG --type WARNING SYSTEM_CONFIGS_SYSLOG_NOT_RUNNING
fi
else
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_SYSLOG
display --to LOG --type INFO NOT_FOUND_CMD 'ps'
fi
#
# Now loop through the system logging configuration files.
#
if [ -z "${SYSLOG_CONFIG_FILE}" ]; then
SYSLOG_CONFIG_FILE="/etc/syslog.conf /etc/rsyslog.conf /etc/syslog-ng/syslog-ng.conf /etc/systemd/journald.conf /etc/systemd/systemd-journald.conf"
fi
if [ "${SYSLOG_CONFIG_FILE}" = "NONE" ]; then
display --to SCREEN+LOG --type PLAIN --result WHITELISTED --color GREEN --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_FILE
else
FILEFOUND=""
REM_LOGGING_FOUND=0
test $ALLOW_SYSLOG_REMOTE_LOGGING -eq 1 && display --to LOG --type INFO SYSTEM_CONFIGS_SYSLOG_REMOTE_ALLOWED
for FNAME in ${SYSLOG_CONFIG_FILE}; do
test ! -f "${FNAME}" && continue
# First, log where the configuration file is located.
RKHTMPVAR="a"
if [ -n "`echo \"${FNAME}\" | grep '/rsyslog\.conf$'`" ]; then
FTYPE="rsyslog"
RKHTMPVAR="an"
elif [ -n "`echo \"${FNAME}\" | grep '/syslog-ng\.conf$'`" ]; then
FTYPE="syslog-ng"
elif [ -n "`echo \"${FNAME}\" | egrep '/(systemd-)?journald\.conf$'`" ]; then
FTYPE="systemd"
else
FTYPE="syslog"
fi
FILEFOUND="${FILEFOUND} ${FTYPE} "
display --to LOG --type INFO SYSTEM_CONFIGS_FILE_FOUND "${RKHTMPVAR}" "${FTYPE}" "`name2text \"${FNAME}\"`"
# Next see if the configuration file allows remote logging.
if [ "${FTYPE}" != "systemd" ]; then
RKHTMPVAR=""
if [ -n "`echo \"${FNAME}\" | egrep '/r?syslog\.conf$'`" ]; then
RKHTMPVAR=`egrep -i '^[^#].*[ ](@|:omrelp:).' "${FNAME}" | egrep -i -v '(@|:omrelp:)127\.'`
else
#
# For syslog-ng we must look for a destination
# block which uses TCP or UDP.
#
RKHTMPVAR=`awk '/^[ ]*destination( | |$)/, /}/ { print $0 }' "${FNAME}" | egrep -i '( | |\{|^)(tcp|udp)6?( | |\(|$)' | egrep -v -i '(tcp|udp)6?[ ]*\([ ]*("[ ]*)?127\.'`
fi
if [ -n "${RKHTMPVAR}" ]; then
REM_LOGGING_FOUND=1
display --to LOG --type INFO SYSTEM_CONFIGS_SYSLOG_REMOTE_LOG "${FTYPE}" "${RKHTMPVAR}"
fi
fi
done
#
# Now display the results. We need to rank these so
# that the warnings are shown before anything else.
#
if [ $SYSLOG_SEEN -eq 1 -a -z "`echo \"${FILEFOUND}\" | egrep ' (syslog|rsyslog|syslog-ng) '`" ]; then
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_FILE
display --to LOG --type WARNING SYSTEM_CONFIGS_SYSLOG_NO_FILE 'syslog'
elif [ $SYSTEMD_SEEN -eq 1 -a -z "`echo \"${FILEFOUND}\" | grep ' systemd '`" ]; then
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_FILE
display --to LOG --type WARNING SYSTEM_CONFIGS_SYSLOG_NO_FILE 'systemd-journald'
elif [ -n "${FILEFOUND}" ]; then
display --to SCREEN+LOG --type PLAIN --result FOUND --color GREEN --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_FILE
else
display --to SCREEN+LOG --type PLAIN --result NOT_FOUND --color GREEN --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_FILE
fi
#
# We only display the remote logging result if a configuration file was found.
#
if [ -n "`echo \"${FILEFOUND}\" | egrep ' (syslog|rsyslog|syslog-ng) '`" ]; then
if [ $ALLOW_SYSLOG_REMOTE_LOGGING -eq 1 ]; then
display --to SCREEN+LOG --type PLAIN --result ALLOWED --color GREEN --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_SYSLOG_REMOTE
elif [ $REM_LOGGING_FOUND -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --result NOT_ALLOWED --color GREEN --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_SYSLOG_REMOTE
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 SYSTEM_CONFIGS_SYSLOG_REMOTE
fi
fi
fi
return
}
do_dev_whitelist_check() {
#
# The check of /dev files has two methods. One uses a simple
# top-level file check, the other is more thorough and does a
# complete 'find' on the /dev directory. However, the check on
# whether the given file is whitelisted is the same for both
# methods. As such, it makes sense to use a function rather than
# repeating the code for each method.
#
FTYPE=`${FILE_CMD} "${RKHTMPVAR}" 2>&1 | awk -F':' '{ print $NF }' | cut -c2-`
if [ $MACOSX -eq 1 -a -n "`echo \"${FTYPE}\" | grep 'universal binary'`" ]; then
FTYPE=`echo "${FTYPE}" | tail ${TAIL_OPT}1`
fi
if [ -z "`echo \"${FTYPE}\" | egrep -v '(character special|block special|socket|fifo \(named pipe\)|symbolic link to|empty|directory|/MAKEDEV:)'`" ]; then
return
fi
#
# Not sure why but '?' doesn't seem to need to be escaped. Neither do parentheses or braces.
# Also, cannot get the '[]' characters to work in the bracket expression. So these are handled individually.
#
FNAMEGREP=`echo "${RKHTMPVAR}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -n "`echo \"${ALLOWDEVFILES}\" | grep \"^${FNAMEGREP}$\"`" ]; then
display --to LOG --type INFO FILESYSTEM_DEV_FILE_WL "`name2text \"${RKHTMPVAR}\"`"
else
FOUNDFILES="${FOUNDFILES}
${RKHTMPVAR}: ${FTYPE}"
fi
return
}
do_filesystem_check() {
#
# This function carries out various checks on the local filesystem.
#
if `check_test filesystem`; then
display --to LOG --type INFO --screen-nl --nl STARTING_TEST filesystem
display --to SCREEN+LOG --type PLAIN --screen-indent 2 FILESYSTEM_START
else
display --to LOG --type INFO --nl USER_DISABLED_TEST filesystem
return
fi
if [ ! -d "/dev" ]; then
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 FILESYSTEM_DEV_CHECK
display --to LOG --type WARNING FILESYSTEM_DEV_CHECK_NO_DEV
elif [ -z "${FILE_CMD}" ]; then
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --log-indent 2 --screen-indent 4 FILESYSTEM_DEV_CHECK
display --to LOG --type INFO NOT_FOUND_CMD 'file'
elif [ "${SCAN_MODE_DEV}" = "THOROUGH" -a -z "${FIND_CMD}" ]; then
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --log-indent 2 --screen-indent 4 FILESYSTEM_DEV_CHECK
display --to LOG --type INFO NOT_FOUND_CMD 'find'
else
#
# Now we can run the check on /dev.
#
display --to LOG --type INFO CONFIG_SCAN_MODE_DEV "${SCAN_MODE_DEV}"
#
# First we expand the whitelist option to ensure
# that any wildcard entries are the most recent.
#
if [ -n "${ALLOWDEVFILE_OPT}" ]; then
ALLOWDEVFILES=`expand_paths ALLOWDEVFILE_OPT`
fi
#
# Note: We do not look for hidden files here - that is,
# those beginning with a dot. Any hidden files will be
# picked up in the next check.
# Note2: Filenames can contain a colon (:), so we need to
# be careful in separating the filename from the file type.
# Note3: We have to cater for *BSD systems which may have
# fdesc/fdescfs mounted. If it is, then we must skip over
# any detected file descriptors.
#
FDESCFS=0
FOUNDFILES=""
if [ $BSDOS -eq 1 ]; then
RKHTMPVAR=`find_cmd mount`
if [ -n "${RKHTMPVAR}" ]; then
test -n "`${RKHTMPVAR} 2>/dev/null | egrep '^fdesc(fs)? .*type fdesc'`" && FDESCFS=1
else
display --to LOG --type INFO NOT_FOUND_CMD 'mount'
fi
fi
if [ "${SCAN_MODE_DEV}" = "LAZY" ]; then
for RKHTMPVAR in /dev/*; do
test -d "${RKHTMPVAR}" -o -h "${RKHTMPVAR}" && continue
if [ $FDESCFS -eq 1 ]; then
test -n "`echo \"${RKHTMPVAR}/\" | grep \"^/dev/fd/[0-9][0-9]*/\"`" && continue
fi
do_dev_whitelist_check
done
else
IFS=$IFSNL
for RKHTMPVAR in `${FIND_CMD} /dev ! -type d -a ! -type l 2>/dev/null`; do
if [ $FDESCFS -eq 1 ]; then
test -n "`echo \"${RKHTMPVAR}/\" | grep \"^/dev/fd/[0-9][0-9]*/\"`" && continue
fi
test -z "`echo \"${RKHTMPVAR}\" | grep '/\.[^/]*$'`" && do_dev_whitelist_check
done
IFS=$RKHIFS
fi
#
# Now display the results.
#
FOUNDFILES=`echo "${FOUNDFILES}" | sed -e '/^$/d'`
if [ -z "${FOUNDFILES}" ]; then
display --to SCREEN+LOG --type PLAIN --result NONE_FOUND --color GREEN --log-indent 2 --screen-indent 4 FILESYSTEM_DEV_CHECK
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 FILESYSTEM_DEV_CHECK
display --to LOG --type WARNING FILESYSTEM_DEV_FILE_FOUND '/dev'
IFS=$IFSNL
for RKHTMPVAR in ${FOUNDFILES}; do
FTYPE=`echo "${RKHTMPVAR}" | awk -F':' '{ print $NF }' | cut -c2-`
FNAME=`echo "${RKHTMPVAR}" | sed -e 's/: [^:]*$//'`
display --to LOG --type PLAIN --log-indent 9 NAME "`name2text \"${FNAME}\"`: ${FTYPE}"
done
IFS=$RKHIFS
fi
fi
#
# Now we check various directories for hidden files and
# directories. We must have the 'file' command for this
# test to run.
#
# First we look in two sets of directories. One set we search
# recursively, using 'find', the other set we only search to
# one-level. If we have no 'find' command, then all the
# directories are only searched to one-level.
#
if [ -z "${FILE_CMD}" ]; then
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --log-indent 2 --screen-indent 4 FILESYSTEM_HIDDEN_CHECK
display --to LOG --type INFO NOT_FOUND_CMD 'file'
return
fi
FOUNDDIRS=""
FOUNDFILES=""
LOOKINDIRS=""
SHORTSEARCHDIRS="/usr /etc"
LONGSEARCHDIRS="/dev /bin /usr/man /usr/share/man /usr/bin /usr/sbin /sbin"
if [ -z "${FIND_CMD}" ]; then
SHORTSEARCHDIRS="${SHORTSEARCHDIRS} ${LONGSEARCHDIRS}"
LONGSEARCHDIRS=""
fi
for DIR in ${SHORTSEARCHDIRS}; do
if [ -d "${DIR}" ]; then
RKHTMPVAR=`ls -1d ${DIR}/.* 2>/dev/null | egrep -v '/\.\.?$'`
test -n "${RKHTMPVAR}" && LOOKINDIRS="${LOOKINDIRS}
${RKHTMPVAR}"
fi
done
for DIR in ${LONGSEARCHDIRS}; do
if [ -d "${DIR}" ]; then
RKHTMPVAR=`${FIND_CMD} "${DIR}" -name ".*" 2>/dev/null`
test -n "${RKHTMPVAR}" && LOOKINDIRS="${LOOKINDIRS}
${RKHTMPVAR}"
fi
done
#
# We expand the whitelisting options to ensure that any
# wildcard entries are the most recent.
#
if [ -n "${ALLOWHIDDENFILE_OPT}" ]; then
ALLOWHIDDENFILES=`expand_paths ALLOWHIDDENFILE_OPT`
fi
if [ -n "${ALLOWHIDDENDIR_OPT}" ]; then
ALLOWHIDDENDIRS=`expand_paths ALLOWHIDDENDIR_OPT`
fi
#
# Next we look for any whitelisted files and directories. We also
# exclude certain types of files.
#
IFS=$IFSNL
for FNAME in ${LOOKINDIRS}; do
if [ $FDESCFS -eq 1 ]; then
test -n "`echo \"${FNAME}/\" | grep \"^/dev/fd/[0-9][0-9]*/\"`" && continue
fi
FTYPE=`${FILE_CMD} "${FNAME}" 2>&1 | awk -F':' '{ print $NF }' | cut -c2-`
test -n "`echo \"${FTYPE}\" | egrep 'character special|block special|empty'`" && continue
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ -n "`echo \"${FTYPE}\" | grep 'directory'`" ]; then
if [ -n "`echo \"${ALLOWHIDDENDIRS}\" | grep \"^${FNAMEGREP}$\"`" ]; then
display --to LOG --type INFO FILESYSTEM_HIDDEN_DIR_WL "`name2text \"${FNAME}\"`"
else
FOUNDDIRS="${FOUNDDIRS}
${FNAME}: ${FTYPE}"
fi
else
if [ -n "`echo \"${ALLOWHIDDENFILES}\" | grep \"^${FNAMEGREP}$\"`" ]; then
display --to LOG --type INFO FILESYSTEM_HIDDEN_FILE_WL "`name2text \"${FNAME}\"`"
else
FOUNDFILES="${FOUNDFILES}
${FNAME}: ${FTYPE}"
fi
fi
done
IFS=$RKHIFS
FOUNDDIRS=`echo "${FOUNDDIRS}" | sed -e '/^$/d'`
FOUNDFILES=`echo "${FOUNDFILES}" | sed -e '/^$/d'`
#
# Now display the results.
#
if [ -z "${FOUNDDIRS}" -a -z "${FOUNDFILES}" ]; then
display --to SCREEN+LOG --type PLAIN --result NONE_FOUND --color GREEN --log-indent 2 --screen-indent 4 FILESYSTEM_HIDDEN_CHECK
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 FILESYSTEM_HIDDEN_CHECK
IFS=$IFSNL
for RKHTMPVAR in ${FOUNDDIRS}; do
FTYPE=`echo "${RKHTMPVAR}" | awk -F':' '{ print $NF }' | cut -c2-`
FNAME=`echo "${RKHTMPVAR}" | sed -e 's/: [^:]*$//'`
if [ "${FTYPE}" = "directory" ]; then
display --to LOG --type WARNING FILESYSTEM_HIDDEN_DIR_FOUND "`name2text \"${FNAME}\"`"
else
display --to LOG --type WARNING FILESYSTEM_HIDDEN_DIR_FOUND "`name2text \"${FNAME}\"`: ${FTYPE}"
fi
done
for RKHTMPVAR in ${FOUNDFILES}; do
FTYPE=`echo "${RKHTMPVAR}" | awk -F':' '{ print $NF }' | cut -c2-`
FNAME=`echo "${RKHTMPVAR}" | sed -e 's/: [^:]*$//'`
display --to LOG --type WARNING FILESYSTEM_HIDDEN_FILE_FOUND "`name2text \"${FNAME}\"`: ${FTYPE}"
done
IFS=$RKHIFS
fi
#
# Next check if any configured log files are missing.
#
FOUNDFILES=""
if [ -n "${LOGFILE_MISSING}" ]; then
MISSINGFILES=""
for FNAME in ${LOGFILE_MISSING}; do
if [ ! -f "${FNAME}" ]; then
MISSINGFILES="${MISSINGFILES}
${FNAME}"
fi
done
#
# Now show the results.
#
MISSINGFILES=`echo "${MISSINGFILES}" | sed -e '/^$/d'`
if [ -z "${MISSINGFILES}" ]; then
display --to SCREEN+LOG --type PLAIN --result NONE_MISSING --color GREEN --log-indent 2 --screen-indent 4 FILESYSTEM_LOGFILE_MISSING
else
FOUNDFILES="${MISSINGFILES}"
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 FILESYSTEM_LOGFILE_MISSING
IFS=$IFSNL
for FNAME in ${MISSINGFILES}; do
display --to LOG --type WARNING FILESYSTEM_LOGFILE_MISSING_FOUND "`name2text \"${FNAME}\"`"
done
IFS=$RKHIFS
fi
else
display --to LOG --type PLAIN --result SKIPPED --log-indent 2 FILESYSTEM_LOGFILE_MISSING
fi
#
# Next check if any configured log files are empty or missing.
#
if [ -n "${LOGFILE_EMPTY}" ]; then
EMPTYFILES=""
MISSINGFILES=""
for FNAME in ${LOGFILE_EMPTY}; do
if [ ! -f "${FNAME}" ]; then
#
# Only record a missing log file if the previous
# missing log file test didn't check it.
#
if [ -z "`echo \"${FOUNDFILES}\" | grep \"^${FNAME}$\"`" ]; then
MISSINGFILES="${MISSINGFILES}
${FNAME}"
fi
elif [ ! -s "${FNAME}" ]; then
EMPTYFILES="${EMPTYFILES}
${FNAME}"
fi
done
#
# Now show the results.
#
EMPTYFILES=`echo "${EMPTYFILES}" | sed -e '/^$/d'`
MISSINGFILES=`echo "${MISSINGFILES}" | sed -e '/^$/d'`
if [ -z "${EMPTYFILES}" -a -z "${MISSINGFILES}" ]; then
display --to SCREEN+LOG --type PLAIN --result NONE_FOUND --color GREEN --log-indent 2 --screen-indent 4 FILESYSTEM_LOGFILE_EMPTY
else
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 FILESYSTEM_LOGFILE_EMPTY
IFS=$IFSNL
for FNAME in ${EMPTYFILES}; do
display --to LOG --type WARNING FILESYSTEM_LOGFILE_EMPTY_FOUND "`name2text \"${FNAME}\"`"
done
for FNAME in ${MISSINGFILES}; do
display --to LOG --type WARNING FILESYSTEM_LOGFILE_MISSING_FOUND "`name2text \"${FNAME}\"`"
done
IFS=$RKHIFS
fi
else
display --to LOG --type PLAIN --result SKIPPED --log-indent 2 FILESYSTEM_LOGFILE_EMPTY
fi
return
}
do_local_host_checks() {
#
# This function carries out a sequence of tests on the local
# host.
#
if `check_test local_host`; then
display --to LOG --type INFO --screen-nl --nl STARTING_TEST local_host
display --to SCREEN+LOG --type PLAIN --color YELLOW CHECK_LOCALHOST
else
display --to LOG --type INFO --nl USER_DISABLED_TEST local_host
return
fi
#
# We start by performing checks on the startup files.
#
do_system_startup_file_checks
#
# Now we check the /etc/passwd file, and run some checks
# on the accounts and groups.
#
do_group_accounts_check
#
# Next check some of the system configuration files.
#
do_system_config_files_check
#
# Finally check the filesystem for suspicious files.
#
do_filesystem_check
keypresspause
return
}
do_app_checks() {
#
# This function carries out a sequence of application checks.
#
if `check_test apps`; then
display --to LOG --type INFO --screen-nl --nl STARTING_TEST apps
else
display --to LOG --type INFO --nl USER_DISABLED_TEST apps
return
fi
#
# First we check that our apps data file is usable.
#
if [ ! -e "${DB_PATH}/programs_bad.dat" -o ! -s "${DB_PATH}/programs_bad.dat" ]; then
display --to SCREEN+LOG --type PLAIN --color RED --result WARNING CHECK_APPS
display --to LOG --type WARNING APPS_DAT_MISSING "${DB_PATH}/programs_bad.dat"
return
elif [ ! -f "${DB_PATH}/programs_bad.dat" -o -h "${DB_PATH}/programs_bad.dat" ]; then
display --to SCREEN+LOG --type PLAIN --color RED --result WARNING CHECK_APPS
display --to LOG --type WARNING APPS_DAT_NOTAFILE "${DB_PATH}/programs_bad.dat"
return
fi
display --to SCREEN+LOG --type PLAIN --color YELLOW --nl-after CHECK_APPS
#
# We loop through the applications and obtain the version number.
# This is then checked against the file of known bad versions.
# We build up a list of application names, the version number,
# and whether it is known to be bad or not. When this has all
# been done, we then display the results.
#
# The results line for each application is made up of percent (%)
# delimited fields. They are:
#
# application%description%version%if known bad%whole version number
#
# A 'version' number of '-1' means the application was not found.
#
# An 'if known bad' number of:
#
# '-1' means a specific version of the application is whitelisted,
# '-2' means the application is whitelisted, regardless of version.
#
APPS_COUNT=0
APP_RESULTS=""
APP_NAMES="exim:Exim MTA
gpg:GnuPG
httpd:Apache
named:Bind DNS
openssl:OpenSSL
php:PHP
procmail:Procmail MTA
proftpd:ProFTPD
sshd:OpenSSH"
APPS_TOTAL_COUNT=`echo "${APP_NAMES}" | wc -l | tr -d ' '`
IFS=$IFSNL
for APP in ${APP_NAMES}; do
APP=`echo ${APP} | sed -e 's/^[ ]*//'`
APPLICATION=`echo ${APP} | cut -d: -f1`
APPLICATION_DESC=`echo ${APP} | cut -d: -f2-`
IFS=$RKHIFS
APP_CMD_FOUND=`find_cmd ${APPLICATION}`
IFS=$IFSNL
if [ -z "${APP_CMD_FOUND}" ]; then
APP_RESULTS="${APP_RESULTS}
${APPLICATION}%${APPLICATION_DESC}%-1"
continue
fi
#
# Find out the version of the application.
#
APPS_COUNT=`expr ${APPS_COUNT} + 1`
VERSION=""
WHOLE_VERSION=""
#
# Applications which are whitelisted completely (no specific
# version number), are handled first.
#
if [ -n "`echo \"${APP_WHITELIST}\" | grep \" ${APPLICATION} \"`" ]; then
APP_RESULTS="${APP_RESULTS}
${APPLICATION}%${APPLICATION_DESC}%0%-2"
else
case "${APPLICATION}" in
exim)
WHOLE_VERSION=`${APP_CMD_FOUND} -bV 2>/dev/null`
VERSION=`echo "${WHOLE_VERSION}" | grep '^Exim version [0-9]' | awk '{ print $3 }'`
;;
gpg)
WHOLE_VERSION=`${APP_CMD_FOUND} --version --homedir / 2>/dev/null`
VERSION=`echo "${WHOLE_VERSION}" | grep 'GnuPG' | awk '{ print $3 }'`
;;
httpd)
WHOLE_VERSION=`${APP_CMD_FOUND} -v 2>/dev/null`
VERSION=`echo "${WHOLE_VERSION}" | grep -i '^Server version:[ ][ ]*Apache/[0-9]' | cut -d' ' -f3 | cut -d'/' -f2`
;;
named)
WHOLE_VERSION=`${APP_CMD_FOUND} -v 2>/dev/null`
VERSION=`echo "${WHOLE_VERSION}" | egrep '^(named|BIND)[ ][ ]*[0-9]' | grep -v '/' | awk '{ print $2 }'`
if [ -n "`echo \"${VERSION}\" | grep '^[^-]*\.[0-9][0-9]*-P[^-]*-'`" ]; then
VERSION=`echo "${VERSION}" | cut -d'-' -f1-2`
elif [ -n "`echo \"${VERSION}\" | grep '^[^-]*\.[0-9][0-9]*-[^P]'`" ]; then
VERSION=`echo "${VERSION}" | cut -d'-' -f1`
fi
if [ -z "${VERSION}" ]; then
VERSION=`${APP_CMD_FOUND} -v | awk '{ print $2 }'`
fi
;;
openssl)
WHOLE_VERSION=`${APP_CMD_FOUND} version 2>/dev/null`
VERSION=`echo "${WHOLE_VERSION}" | grep '^OpenSSL[ ][ ]*[0-9]' | cut -d' ' -f2`
if [ -n "`echo \"${VERSION}\" | grep '^[^-]*-fips'`" ]; then
VERSION=`echo "${VERSION}" | cut -d'-' -f1`
fi
;;
php)
WHOLE_VERSION=`${APP_CMD_FOUND} -v 2>/dev/null`
VERSION=`echo "${WHOLE_VERSION}" | grep '^PHP[ ][ ]*[0-9]' | awk '{ print $2 }' | cut -d'-' -f1`
;;
procmail)
WHOLE_VERSION=`${APP_CMD_FOUND} -v 2>&1`
VERSION=`echo "${WHOLE_VERSION}" | grep '^procmail[ ][ ]*v[0-9]' | awk '{ print $2 }' | sed -e 's/^v//'`
;;
proftpd)
WHOLE_VERSION=`${APP_CMD_FOUND} -v 2>&1`
VERSION=`echo "${WHOLE_VERSION}" | sed -e 's/^.*\(ProFTPD.*\)$/\1/' | grep '^ProFTPD[ ][ ]*Version[ ][ ]*[0-9]' | awk '{ print $3 }'`
;;
sshd)
WHOLE_VERSION=`${APP_CMD_FOUND} -t -d 2>&1`
VERSION=`echo "${WHOLE_VERSION}" | grep 'sshd version OpenSSH' | sed -e 's/^.*sshd version OpenSSH_//' | cut -d' ' -f1`
if [ -n "`echo \"${VERSION}\" | grep '+'`" ]; then
VERSION=`echo "${VERSION}" | cut -d'+' -f1`
fi
;;
esac
VERSION=`echo "${VERSION}" | tr -d '\r'`
WHOLE_VERSION=`echo "${WHOLE_VERSION}" | tr -d '\r'`
if [ -z "${VERSION}" ]; then
WHOLE_VERSION=`echo "${WHOLE_VERSION}" | tr '\n' '%'`
APP_RESULTS="${APP_RESULTS}
${APPLICATION}%${APPLICATION_DESC}%%0%${WHOLE_VERSION}"
continue
fi
#
# Now see if the application version is known to be bad.
#
RKHTMPVAR=`echo "${VERSION}" | sed -e 's/\./\\\./g'`
if [ -n "`echo \"${APP_WHITELIST}\" | grep -i \" ${APPLICATION}:${RKHTMPVAR} \"`" ]; then
APP_RESULTS="${APP_RESULTS}
${APPLICATION}%${APPLICATION_DESC}%${VERSION}%-1"
elif [ -n "`egrep -i \"^${APPLICATION}:.* ${RKHTMPVAR}( |$)\" \"${DB_PATH}/programs_bad.dat\" 2>&1`" ]; then
APPS_FAILED_COUNT=`expr ${APPS_FAILED_COUNT} + 1`
APP_RESULTS="${APP_RESULTS}
${APPLICATION}%${APPLICATION_DESC}%${VERSION}%1"
else
APP_RESULTS="${APP_RESULTS}
${APPLICATION}%${APPLICATION_DESC}%${VERSION}%0"
fi
fi
done
IFS=$RKHIFS
#
# Now display the results.
#
if [ $APPS_COUNT -eq 0 ]; then
display --to SCREEN+LOG --type PLAIN --color YELLOW --nl --result SKIPPED CHECK_APPS
display --to LOG --type INFO APPS_NONE_FOUND
else
IFS=$IFSNL
for RKHTMPVAR in ${APP_RESULTS}; do
APPLICATION=`echo "${RKHTMPVAR}" | cut -d% -f1`
APPLICATION_DESC=`echo "${RKHTMPVAR}" | cut -d% -f2`
VERSION=`echo "${RKHTMPVAR}" | cut -d% -f3`
if [ -z "${VERSION}" ]; then
WHOLE_VERSION=`echo "${RKHTMPVAR}" | cut -d% -f5- | tr '%' '\n'`
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --log-indent 2 --screen-indent 4 APPS_CHECK "${APPLICATION_DESC}"
if [ -n "${WHOLE_VERSION}" ]; then
display --to LOG --type INFO APPS_CHECK_WHOLE_VERSION_USED "${APPLICATION}" "${WHOLE_VERSION}"
else
display --to LOG --type INFO APPS_CHECK_VERSION_UNKNOWN "${APPLICATION}"
fi
elif [ "${VERSION}" = "-1" ]; then
display --to LOG --type INFO APPS_NOT_FOUND "${APPLICATION}"
else
ISBAD=`echo "${RKHTMPVAR}" | cut -d% -f4`
if [ -n "`echo $ECHOOPT \"${ISBAD}\" | grep '[^-0-9]'`" ]; then
display --to SCREEN+LOG --type PLAIN --result SKIPPED --color YELLOW --log-indent 2 --screen-indent 4 APPS_CHECK "${APPLICATION_DESC}"
display --to LOG --type INFO APPS_CHECK_VERSION_UNKNOWN "${APPLICATION}"
elif [ $ISBAD -eq -2 ]; then
display --to SCREEN+LOG --type PLAIN --result OK --color GREEN --log-indent 2 --screen-indent 4 APPS_CHECK "${APPLICATION_DESC}"
display --to LOG --type INFO APPS_CHECK_WL "${APPLICATION}"
elif [ $ISBAD -eq -1 ]; then
display --to SCREEN+LOG --type PLAIN --result OK --color GREEN --log-indent 2 --screen-indent 4 APPS_CHECK "${APPLICATION_DESC}"
display --to LOG --type INFO APPS_CHECK_VERSION_WL "${APPLICATION}" "${VERSION}"
elif [ $ISBAD -eq 1 ]; then
display --to SCREEN+LOG --type PLAIN --result WARNING --color RED --log-indent 2 --screen-indent 4 APPS_CHECK "${APPLICATION_DESC}"
display --to LOG --type WARNING APPS_CHECK_FOUND "${APPLICATION}" "${VERSION}"
else
display --to SCREEN+LOG --type PLAIN --result OK --color GREEN --log-indent 2 --screen-indent 4 APPS_CHECK "${APPLICATION_DESC}"
display --to LOG --type INFO APPS_CHECK_VERSION_FOUND "${APPLICATION}" "${VERSION}"
fi
fi
done
IFS=$RKHIFS
fi
display --to LOG --type INFO APPS_TOTAL_COUNT $APPS_COUNT $APPS_TOTAL_COUNT
return
}
display_check_summary() {
#
# This function displays a short summary of some of the
# groups of checks performed.
#
if [ $QUIET -eq 0 -o \( $SHOWWARNINGSONLY -eq 1 -a $WARNING_COUNT -gt 0 \) ]; then
RKHTMPVAR=2
else
RKHTMPVAR=1
fi
display --to SCREEN+LOG --type PLAIN --nl ${RKHTMPVAR} SUMMARY_TITLE1
display --to SCREEN+LOG --type PLAIN SUMMARY_TITLE2
#
# Do file properties summary.
#
display --to SCREEN+LOG --type PLAIN --nl SUMMARY_PROP_SCAN
if `check_test properties`; then
if [ $SUMMARY_PROP_REQCMDS -eq 1 ]; then
display --to SCREEN+LOG --type PLAIN --screen-indent 4 SUMMARY_PROP_REQCMDS
fi
display --to SCREEN+LOG --type PLAIN --screen-indent 4 SUMMARY_PROP_COUNT $PROP_FILE_LIST_COUNT
display --to SCREEN+LOG --type PLAIN --screen-indent 4 SUMMARY_PROP_FAILED $PROP_FAILED_COUNT
else
display --to SCREEN+LOG --type PLAIN --screen-indent 4 SUMMARY_CHKS_SKIPPED
fi
#
# Do rootkit check summary.
#
display --to SCREEN+LOG --type PLAIN --nl SUMMARY_RKT_SCAN
if `check_test rootkits || check_test startup_malware` || test $ROOTKIT_COUNT -gt 0; then
RKHTMPVAR2=""
if [ -n "${ROOTKIT_FAILED_NAMES}" ]; then
ROOTKIT_FAILED_NAMES=`echo "${ROOTKIT_FAILED_NAMES}" | sed -e 's/, */,/g; s/,$//'`
IFS=","
for RTKT_NAME in ${ROOTKIT_FAILED_NAMES}; do
if [ -z "`echo \" ${RKHTMPVAR2},\" | grep \" ${RTKT_NAME},\"`" ]; then
RKHTMPVAR2="${RKHTMPVAR2}${RTKT_NAME}, "
else
ROOTKIT_FAILED_COUNT=`expr $ROOTKIT_FAILED_COUNT - 1`
fi
done
IFS=$RKHIFS
RKHTMPVAR2=`echo "${RKHTMPVAR2}" | sed -e 's/, $//'`
fi
display --to SCREEN+LOG --type PLAIN --screen-indent 4 SUMMARY_RKT_COUNT $ROOTKIT_COUNT
display --to SCREEN+LOG --type PLAIN --screen-indent 4 SUMMARY_RKT_FAILED $ROOTKIT_FAILED_COUNT
test -n "${RKHTMPVAR2}" && display --to SCREEN+LOG --type PLAIN --screen-indent 4 SUMMARY_RKT_NAMES "${RKHTMPVAR2}"
else
display --to SCREEN+LOG --type PLAIN --screen-indent 4 SUMMARY_CHKS_SKIPPED
fi
#
# Do application check summary.
#
display --to SCREEN+LOG --type PLAIN --nl SUMMARY_APPS_SCAN
if `check_test apps`; then
display --to SCREEN+LOG --type PLAIN --screen-indent 4 SUMMARY_APPS_COUNT $APPS_COUNT
display --to SCREEN+LOG --type PLAIN --screen-indent 4 SUMMARY_APPS_FAILED $APPS_FAILED_COUNT
else
display --to SCREEN+LOG --type PLAIN --screen-indent 4 SUMMARY_CHKS_SKIPPED
fi
#
# Display the amount of time the system check took.
#
if [ $SHOW_SUMMARY_TIME -gt 0 ]; then
if [ $SHOW_SUMMARY_TIME -eq 1 ]; then
RKHTMPVAR="SCREEN"
elif [ $SHOW_SUMMARY_TIME -eq 2 ]; then
RKHTMPVAR="LOG"
else
RKHTMPVAR="SCREEN+LOG"
fi
if [ $BEGINTIME -eq 0 ]; then
display --to ${RKHTMPVAR} --type PLAIN --nl SUMMARY_NO_SCAN_TIME
else
display --to ${RKHTMPVAR} --type PLAIN --nl SUMMARY_SCAN_TIME "${TOTAL_SCANTIME}"
fi
fi
#
# Display where the log file is located, if there is one.
#
if [ $NOLOG -eq 0 ]; then
display --to SCREEN --type PLAIN --nl --nl-after SUMMARY_LOGFILE "${RKHLOGFILE}"
else
display --to SCREEN --type PLAIN --nl --nl-after SUMMARY_NO_LOGFILE
fi
return
}
do_system_check() {
#
# This function performs the various rootkit and security checks
# for the program. We start by initialising variables used for
# the rootkit checks.
#
display --to LOG --type PLAIN --nl CHECK_START
do_system_check_initialisation
#
# Next, for Solaris we see if we are running Solaris 10 or not.
# This can be useful to know in some of the tests since we will
# use different mechanisms on Solaris 10 from those on Solaris
# 9 and before.
#
SOL_PROC=0
SOLARISX=""
if [ $SUNOS -eq 1 ]; then
#
# If we are running Solaris 10, then see if we have the
# command pathname available.
#
# Solaris 10 and above should have the 'a.out' file
# present. We use the PID of 1 here since it should exist
# on all systems.
#
# If we are running Solaris 10 (or above), then we add
# the '-X' option to the 'lsof' command in order to get
# the deleted files.
#
if [ -h "/proc/1/path/a.out" ]; then
SOLARISX='-X'
test $HAVE_READLINK -eq 1 && SOL_PROC=1
fi
fi
#
# Record the start time if we can. The total time taken for
# scanning will only be calculated and displayed if the
# start time can be set.
#
BEGINTIME=0
ENDTIME=0
if [ -n "$SECONDS" ]; then
BEGINTIME=`echo $SECONDS | cut -d. -f1`
elif [ $BSDOS -eq 1 ]; then
BEGINTIME=`date +%s`
elif [ -n "${PERL_CMD}" ]; then
BEGINTIME=`${PERL_CMD} -e 'printf "%d\n", time;'`
fi
#
# Send a start message to syslog if the user requested that.
#
if [ -n "${USE_SYSLOG}" ]; then
${LOGGER_CMD} -t "${PROGRAM_NAME}" -p ${USE_SYSLOG} "Rootkit hunter check started (version ${PROGRAM_version})"
fi
#
# We start with checks of some of the commands (binaries) and
# libraries on the system, to make sure that they have not
# been tampered with.
#
do_system_commands_checks
#
# Next are the rootkit checks.
#
do_rootkit_checks
#
# Next are some network port, and interface checks.
#
do_network_checks
#
# Next are checks of the files for the local host.
#
do_local_host_checks
#
# Next are checks on specific applications.
#
do_app_checks
#
# Now record the end time.
#
if [ $BEGINTIME -ne 0 ]; then
if [ -n "$SECONDS" ]; then
ENDTIME=`echo $SECONDS | cut -d. -f1`
elif [ $BSDOS -eq 1 ]; then
ENDTIME=`date +%s`
else
ENDTIME=`${PERL_CMD} -e 'printf "%d\n", time;'`
fi
TOTAL_SCANTIME=`expr ${ENDTIME} - ${BEGINTIME}`
TOTALMINS=`expr ${TOTAL_SCANTIME} / 60`
TOTALSECS=`expr ${TOTAL_SCANTIME} % 60`
if [ $TOTALMINS -gt 0 ]; then
if [ $TOTALMINS -eq 1 ]; then
TOTAL_SCANTIME="${TOTALMINS} minute and "
else
TOTAL_SCANTIME="${TOTALMINS} minutes and "
fi
else
TOTAL_SCANTIME=""
fi
if [ $TOTALSECS -eq 1 ]; then
TOTAL_SCANTIME="${TOTAL_SCANTIME}${TOTALSECS} second"
else
TOTAL_SCANTIME="${TOTAL_SCANTIME}${TOTALSECS} seconds"
fi
fi
#
# Display the summary of the results.
#
RKH_WARN_DISPLYD=0
if [ $SHOW_SUMMARY -eq 1 ]; then
#
# Unfortunately we need to do a kludge here!
# The user may have used the '--quiet' option,
# so we need to force the summary to be displayed.
# By resetting the NOTTY variable we can get
# the output shown.
#
OLD_NOTTY=$NOTTY
test $SHOW_SUMMARY_OPT -eq 1 && NOTTY=0
display_check_summary
if [ $SHOW_SUMMARY_WARNINGS_NUMBER -eq 0 ]; then
if [ $WARNING_COUNT -eq 0 ]; then
display --to SCREEN --type PLAIN --nl-after CHECK_WARNINGS_NOT_FOUND
else
RKH_WARN_DISPLYD=1
display --to SCREEN --type PLAIN CHECK_WARNINGS_FOUND
fi
else
if [ $WARNING_COUNT -eq 0 ]; then
display --to SCREEN --type PLAIN --nl-after CHECK_WARNINGS_NOT_FOUND0
else
RKH_WARN_DISPLYD=1
if [ $WARNING_COUNT -eq 1 ]; then
display --to SCREEN --type PLAIN CHECK_WARNINGS_FOUND_NUMBER1
else
display --to SCREEN --type PLAIN CHECK_WARNINGS_FOUND_NUMBER "$WARNING_COUNT"
fi
fi
fi
if [ $WARNING_COUNT -gt 0 ]; then
if [ $NOLOG -eq 1 ]; then
display --to SCREEN --type PLAIN --nl-after CHECK_WARNINGS_FOUND_RERUN
else
display --to SCREEN --type PLAIN --nl-after CHECK_WARNINGS_FOUND_CHK_LOG "${RKHLOGFILE}"
fi
fi
NOTTY=$OLD_NOTTY
fi
#
# Send a finish message to syslog if the user requested that.
#
if [ -n "${USE_SYSLOG}" ]; then
${LOGGER_CMD} -t "${PROGRAM_NAME}" -p ${USE_SYSLOG} "Scanning took ${TOTAL_SCANTIME}"
fi
#
# If some warning or error has been seen, then make sure the
# user is told about it. We also set the return code, to allow
# the user to detect it being non-zero.
#
if [ $WARNING_COUNT -gt 0 ]; then
if [ $SHOWWARNINGSONLY -eq 1 -a $RKH_WARN_DISPLYD -eq 0 ]; then
#
# Unfortunately we need to do a kludge again!
# By requesting that only warnings are shown,
# the following output would not normally be
# displayed (because they are not warnings).
#
OLD_NOTTY=$NOTTY
NOTTY=0
if [ $SHOW_SUMMARY_WARNINGS_NUMBER -eq 0 ]; then
display --to SCREEN --type PLAIN --nl CHECK_WARNINGS_FOUND
else
if [ $WARNING_COUNT -eq 1 ]; then
display --to SCREEN --type PLAIN --nl CHECK_WARNINGS_FOUND_NUMBER1
else
display --to SCREEN --type PLAIN --nl CHECK_WARNINGS_FOUND_NUMBER "$WARNING_COUNT"
fi
fi
if [ $NOLOG -eq 1 ]; then
display --to SCREEN --type PLAIN CHECK_WARNINGS_FOUND_RERUN
else
display --to SCREEN --type PLAIN CHECK_WARNINGS_FOUND_CHK_LOG "${RKHLOGFILE}"
fi
NOTTY=$OLD_NOTTY
fi
if [ -n "${USE_SYSLOG}" ]; then
${LOGGER_CMD} -t "${PROGRAM_NAME}" -p ${USE_SYSLOG} "Please inspect this machine, because it may be infected."
fi
if [ -n "${MAILONWARNING}" ]; then
eval "echo 'Please inspect this machine, because it may be infected.' | ${MAIL_CMD} ${MAILONWARNING}"
fi
RET_CODE=1
fi
return
}
check_os_info() {
#
# This function checks the current O/S information against
# that stored in the rkhunter.dat file. Any change could
# mean that the file properties checks could give several
# false-positive answers. As such we warn users that
# a change has occurred.
#
OS_CHANGED=0
display --to LOG --type PLAIN --nl OSINFO_START
#
# First check if the host name has changed.
#
if [ $WARN_ON_OS_CHANGE -eq 1 ]; then
IND_COUNT=9
OSINFO_WARNING="WARNING"
else
IND_COUNT=6
OSINFO_WARNING="INFO"
display --to LOG --type INFO FILE_PROP_NO_OS_WARNING
fi
OLD_HOST=`grep '^Host:' "${RKHDAT_FILE}" | cut -d: -f2-`
if [ "${HOST_NAME}" != "${OLD_HOST}" ]; then
OS_CHANGED=1
display --to LOG --type "${OSINFO_WARNING}" OSINFO_HOST_CHANGE1
display --to LOG --type PLAIN --log-indent $IND_COUNT OSINFO_HOST_CHANGE2 "${OLD_HOST}" "${HOST_NAME}"
fi
#
# Next check if the O/S name has changed.
#
OLD_OSNAME=`grep '^OS:' "${RKHDAT_FILE}" | cut -d: -f2-`
if [ "${OSNAME}" != "${OLD_OSNAME}" ]; then
OS_CHANGED=1
display --to LOG --type "${OSINFO_WARNING}" OSINFO_OSVER_CHANGE1
display --to LOG --type PLAIN --log-indent $IND_COUNT OSINFO_OSVER_CHANGE2 "${OLD_OSNAME}" "${OSNAME}"
fi
#
# Check if the prelinking status has changed.
#
if [ -z "`grep '^Prelinked:Yes' \"${RKHDAT_FILE}\"`" ]; then
OLD_PRELINK=0
else
OLD_PRELINK=1
fi
if [ $PRELINKED -ne $OLD_PRELINK ]; then
OS_CHANGED=1
if [ $PRELINKED -eq 1 ]; then
display --to LOG --type "${OSINFO_WARNING}" OSINFO_PRELINK_CHANGE ''
else
display --to LOG --type "${OSINFO_WARNING}" OSINFO_PRELINK_CHANGE 'not '
fi
fi
#
# Check if the system architecture has changed. We treat
# the i386-type architectures as the same. We also treat
# the sun-type archictures the same as 'sparc'.
#
OLD_ARCH=`grep '^Arch:' "${RKHDAT_FILE}" | cut -d: -f2-`
if [ -n "`echo ${OLD_ARCH} | grep 'i[0-9]86'`" ]; then
OLD_ARCH_TYPE="i386"
elif [ -n "`echo ${OLD_ARCH} | grep 'sun[0-9][a-z]'`" -o -n "`echo ${OLD_ARCH} | grep 'sparc'`" ]; then
OLD_ARCH_TYPE="sparc"
else
OLD_ARCH_TYPE=$OLD_ARCH
fi
if [ -n "`echo ${ARCH} | grep 'i[0-9]86'`" ]; then
ARCH_TYPE="i386"
elif [ -n "`echo ${ARCH} | grep 'sun[0-9][a-z]'`" -o -n "`echo ${ARCH} | grep 'sparc'`" ]; then
ARCH_TYPE="sparc"
else
ARCH_TYPE=$ARCH
fi
if [ "${OLD_ARCH_TYPE}" != "${ARCH_TYPE}" ]; then
OS_CHANGED=1
display --to LOG --type "${OSINFO_WARNING}" OSINFO_ARCH_CHANGE1
display --to LOG --type PLAIN --log-indent $IND_COUNT OSINFO_ARCH_CHANGE2 "${OLD_ARCH}" "${ARCH}"
fi
if [ $OS_CHANGED -eq 1 ]; then
display --to LOG --type PLAIN --log-indent $IND_COUNT OSINFO_MSG1
if [ $UPDT_ON_OS_CHANGE -eq 0 ]; then
display --to LOG --type PLAIN --log-indent $IND_COUNT OSINFO_MSG2
test $WARN_ON_OS_CHANGE -eq 1 && display --to LOG --type WARNING --nl PROPUPD_WARN
else
PROP_UPDATE=1
display --to LOG --type INFO OSINFO_DO_UPDT
fi
else
display --to LOG --type INFO OSINFO_END
fi
return
}
set_file_prop_dirs_files() {
#
# This function sets up the list of directories we look in,
# and the list of files we look for, in order to perform
# the file properties checks.
#
# Any non-existent files are simply left in for the checks
# to skip over. However, any symbolic links are expanded and
# the result of the link is added to the list. This avoids
# any attempt to simply replace a link, and avoid it being
# detected by the file hash value check.
#
# We also check to see if any of the directories are links.
# If it is then we add the link target directory.
#
PROP_DIR_LIST=""
#
# We have to change BINDIR to a newline-separated list here
# because USER_DIR_LIST is one. If USER_DIR_LIST contained
# a space anywhere, then the directories would not be searched.
#
BINPS=`echo ${BINPATHS} | tr ' ' '\n'`
IFS=$IFSNL
for DIR in ${BINPS} ${USER_DIR_LIST}; do
test ! -d "${DIR}" && continue
if [ -h "${DIR}" -a $HAVE_READLINK -eq 1 ]; then
LINKDIR=`${READLINK_CMD} -f "${DIR}"`
else
LINKDIR="${DIR}"
fi
if [ -z "`echo \"${PROP_DIR_LIST}\" | grep \"^${LINKDIR}$\"`" ]; then
PROP_DIR_LIST="${PROP_DIR_LIST}
${LINKDIR}"
fi
done
IFS=$RKHIFS
PROP_FILE_LIST="adduser amd awk basename bash bget cat chattr checkproc
chkconfig chmod chown chroot cp cron csh curl cut date depmod df
diff dirname dmesg dpkg dpkg-query du echo ed egrep elinks env fgrep
file find fsck fuser GET grep groupadd groupdel groupmod groups grpck head id
ifconfig ifdown ifstatus ifup inetd init insmod ip kallsyms kill
killall ksyms kudzu last lastlog ldd less links locate logger login
ls lsattr lsmod lsof lynx mail md5 md5sum mktemp mlocate modinfo
modload modprobe modstat modunload more mount mv netstat newgrp
newsyslog nologin passwd perl pgrep ping pkgdb pkg_info pkill prelink ps pstree pwck
pwd readlink rkhunter rmmod route rpm rsyslogd runcon runlevel sed sestatus sh
sha1 sha1sum sha224 sha224sum sha256 sha256sum sha384 sha384sum sha512
sha512sum size skdet slocate sockstat sort ssh sshd stat strace strings su sudo
sulogin sysctl syslogd systat tail tcpd telnet test top touch tr uname
uniq useradd userdel usermod users vipw vmstat w watch wc wget whatis
whereis which who whoami xinetd"
#
# We add in some extra commands to check depending on the O/S.
#
case "${OPERATING_SYSTEM}" in
SunOS)
PROP_FILE_LIST="${PROP_FILE_LIST} gawk gbasename gcat gchmod gchown
gcksum gcp gcut gdate gdiff gdiff3 gdirname gdu gecho
gegrep genv gfile gfind ggrep ggroups ghead gid glocate
gls gmd5sum gmv gpwd gsed gsize gsort gstrings gsum
gtail gtest gtouch guname guniq gusers gwc gwho gwhoami
inetadm nawk truss unhide unhide-posix unhide-tcp"
;;
FreeBSD|DragonFly)
PROP_FILE_LIST="${PROP_FILE_LIST} fstat kldload kldstat kldunload procstat
unhide unhide-posix unhide-tcp"
;;
*BSD)
PROP_FILE_LIST="${PROP_FILE_LIST} unhide unhide-posix unhide-tcp"
;;
Linux)
PROP_FILE_LIST="${PROP_FILE_LIST} unhide unhide-linux unhide-posix unhide-tcp"
if [ -n "`uname -r | grep '^2\.6'`" ]; then
PROP_FILE_LIST="${PROP_FILE_LIST} unhide-linux26"
fi
;;
Darwin)
PROP_FILE_LIST="${PROP_FILE_LIST} shasum launchctl dscl"
;;
esac
#
# Next we quickly loop through the user supplied list of files,
# and ignore any that are already in the builtin list. At this
# point we also change PROP_FILE_LIST from a space-separated
# list to a newline-separated one. We have to do this because
# we are about to add in the user-supplied pathnames.
#
PROP_FILE_LIST=`echo ${PROP_FILE_LIST} | tr ' ' '\n'`
if [ -n "${USER_SIMPLE_FILE_LIST}" ]; then
RKHTMPVAR=""
IFS=$IFSNL
for FNAME in ${USER_SIMPLE_FILE_LIST}; do
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
test -z "`echo \"${PROP_FILE_LIST}\" | grep \"^${FNAMEGREP}$\"`" && RKHTMPVAR="${RKHTMPVAR}
${FNAME}"
done
IFS=$RKHIFS
USER_SIMPLE_FILE_LIST=`echo "${RKHTMPVAR}" | sed -e '/^$/d'`
if [ -n "${USER_SIMPLE_FILE_LIST}" ]; then
PROP_FILE_LIST="${PROP_FILE_LIST}
${USER_SIMPLE_FILE_LIST}"
fi
fi
#
# Now loop through the file list and look for any
# symbolic links. If a link is found, then add on
# the file and directory that the link points to.
#
if [ $HAVE_READLINK -eq 1 ]; then
EXTRA_DIRS=""
EXTRA_FILES=""
IFS=$IFSNL
for DIR in ${PROP_DIR_LIST}; do
for FNAME in ${PROP_FILE_LIST}; do
if [ -h "${DIR}/${FNAME}" ]; then
RKHTMPVAR=`${READLINK_CMD} -f "${DIR}/${FNAME}"`
test ! -f "${RKHTMPVAR}" && continue
#
# Get the link target directory name.
#
test -n "${DIRNAME_CMD}" && LINKDIR=`${DIRNAME_CMD} "${RKHTMPVAR}"` || LINKDIR=`echo "${RKHTMPVAR}" | sed -e 's:/[^/]*$::'`
#
# Now see if we already have the directory listed.
# If not, then we add it on.
#
RKHTMPVAR3="${PROP_DIR_LIST}
${EXTRA_DIRS}"
if [ -z "`echo \"${RKHTMPVAR3}\" | grep \"^${LINKDIR}$\"`" ]; then
EXTRA_DIRS="${EXTRA_DIRS}
${LINKDIR}"
fi
#
# Now get the link target file name.
#
LINKFNAME=`echo "${RKHTMPVAR}" | sed -e 's:^.*/::'`
FNAMEGREP=`echo "${LINKFNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
#
# And finally check if we already have it listed.
#
RKHTMPVAR3="${PROP_FILE_LIST}
${EXTRA_FILES}"
if [ -z "`echo \"${RKHTMPVAR3}\" | grep \"^${FNAMEGREP}$\"`" ]; then
EXTRA_FILES="${EXTRA_FILES}
${LINKFNAME}"
fi
fi
done
done
IFS=$RKHIFS
EXTRA_DIRS=`echo "${EXTRA_DIRS}" | sed -e '/^$/d'`
EXTRA_FILES=`echo "${EXTRA_FILES}" | sed -e '/^$/d'`
test -n "${EXTRA_DIRS}" && PROP_DIR_LIST="${PROP_DIR_LIST}
${EXTRA_DIRS}"
test -n "${EXTRA_FILES}" && PROP_FILE_LIST="${PROP_FILE_LIST}
${EXTRA_FILES}"
fi
PROP_FILE_LIST_TOTAL=`echo "${PROP_FILE_LIST}" | wc -l | tr -d ' '`
return
}
check_test() {
#
# This function will check whether a given test name should
# be run or not. It returns 0 if the test is to be run,
# and 1 if it is not.
#
if [ "${ENABLE_TESTS}" = "all" -o -n "`echo \" ${ENABLE_TESTS} \" | grep \" $1 \"`" ]; then
if [ "${DISABLE_TESTS}" = "none" -o -z "`echo \" ${DISABLE_TESTS} \" | grep \" $1 \"`" ]; then
return 0
fi
fi
return 1
}
display_tests() {
#
# This function is used to simply output all the available
# tests and test group names. If a group name itself contains
# a group name, then that second group name is omitted. It
# could be confusing if it was included.
#
RKHTMPVAR2=`echo "all none ${KNOWN_TESTS}" | tr ' ' '\n' | sort | tr '\n' ' '`
GROUPED_TESTS=`echo "${GROUPED_TESTS}" | tr ' ' '\n' | sort | tr '\n' ' '`
display --to SCREEN --type PLAIN --nl LIST_TESTS
while test -n "${RKHTMPVAR2}"; do
STR=`echo ${RKHTMPVAR2} | cut -d' ' -f1-6`
RKHTMPVAR2=`echo ${RKHTMPVAR2} | cut -d' ' -f7-`
echo " ${STR}"
test "${STR}" = "${RKHTMPVAR2}" && RKHTMPVAR2=""
done
display --to SCREEN --type PLAIN --nl LIST_GROUPED_TESTS
#
# Sort out the maximum group name length, so we can do some
# simple formatting of the output.
#
MAX=0
for STR in ${GROUPED_TESTS}; do
LEN=`echo "${STR}" | cut -d: -f1 | wc -c | tr -d ' '`
test $LEN -gt $MAX && MAX=$LEN
done
#
# Now loop through the group names.
#
RKHTMPVAR2=" `echo ${GROUPED_TESTS}`"
for STR in ${GROUPED_TESTS}; do
TEST_NAMES=""
GROUP_NAME=`echo "${STR}" | cut -d: -f1`
#
# Add on spaces to expand the group name to the maximum.
#
LEN=`echo "${GROUP_NAME}" | wc -c | tr -d ' '`
LEN=`expr $MAX - $LEN`
test $LEN -gt 0 && GROUP_NAME="${GROUP_NAME} `echo \"${BLANK_LINE}\" | cut -d' ' -f1-$LEN`"
#
# Check through the list of tests for this group name.
# If the test name is a group name itself, then go to
# the next test name, otherwise add it to our list of
# test names.
#
for TEST in `echo "${STR}" | cut -d: -f2- | tr ':' ' '`; do
RKHTMPVAR=`echo "${RKHTMPVAR2}" | grep " ${TEST}:"`
if [ -z "${RKHTMPVAR}" ]; then
TEST_NAMES="${TEST_NAMES}:${TEST}"
else
continue
fi
done
#
# Finally, sort our list of test names and display them.
#
TEST_NAMES=`echo "${TEST_NAMES}" | sed -e 's/^://' | tr ':' '\n' | sort | tr '\n' ' '`
echo " ${GROUP_NAME} => ${TEST_NAMES}"
done
return
}
display_languages() {
#
# This function is used to simply output all the available
# languages in a basic format of 10 per line.
#
KNOWN_LANGS=`ls -1 ${DB_PATH}/i18n 2>/dev/null | sort`
display --to SCREEN --type PLAIN --nl LIST_LANGS
while test -n "${KNOWN_LANGS}"; do
STR=`echo ${KNOWN_LANGS} | cut -d' ' -f1-10`
KNOWN_LANGS=`echo ${KNOWN_LANGS} | cut -d' ' -f11-`
echo " ${STR}"
test "${STR}" = "${KNOWN_LANGS}" && KNOWN_LANGS=""
done
return
}
display_perl_modules() {
#
# This function is used to display the status of
# the installed perl modules which may be required.
#
display --to SCREEN --type PLAIN --nl LIST_PERL
for MODNAME in perl ${LIST_MODULES}; do
if [ "${MODNAME}" = "perl" ]; then
MODNAME="perl command"
test -n "${PERL_CMD}" && MOD_INSTALLED="" || MOD_INSTALLED="NOT installed"
else
MOD_INSTALLED=`${PERL_CMD} "${SCRIPT_PATH}/check_modules.pl" ${MODNAME} 2>/dev/null | grep 'NOT installed'`
fi
MODLEN=`echo "${MODNAME}" | wc -c | tr -d ' '`
NUM_SPACES=`expr 28 - ${MODLEN}`
test $NUM_SPACES -lt 1 && NUM_SPACES=1
SPACES=`echo "${BLANK_LINE}" | cut -c1-$NUM_SPACES`
if [ -z "${MOD_INSTALLED}" ]; then
echo $ECHOOPT " ${MODNAME}${SPACES}Installed"
else
echo $ECHOOPT " ${MODNAME}${SPACES} MISSING"
fi
test "${MODNAME}" = "perl command" -a -z "${PERL_CMD}" && break
done
return
}
display_propfiles() {
#
# This function is used to display the list of files which
# would be searched for when using the '--propupd' function.
#
# Get any user-supplied files and directories.
get_user_fileprop_list
# Get the builtin list of files and directories.
set_file_prop_dirs_files
# Create the file of entries used by the '--propupd' function.
create_rkh_file_prop_list
# Finally just dump out the list of file names.
awk -F'/' '{ print $NF }' "${RKH_FILEPROP_LIST}" | sort | uniq
return
}
display_rootkits() {
#
# This function is used to simply output all the rootkit
# names which rkhunter will check for.
#
RKHTMPVAR2=`echo ${KNOWN_ROOTKITS} | sed -e 's/^,*//; s/,$//'`
display --to SCREEN --type PLAIN --nl LIST_RTKTS
while test -n "${RKHTMPVAR2}"; do
STR=`echo ${RKHTMPVAR2} | cut -d',' -f1-6`
RKHTMPVAR2=`echo ${RKHTMPVAR2} | cut -d',' -f7-`
if [ "${STR}" = "${RKHTMPVAR2}" -o -z "${RKHTMPVAR2}" ]; then
RKHTMPVAR2=""
else
STR="${STR},"
fi
echo " ${STR}"
done
return
}
get_lock() {
#
# This function attempts to get the lock file. If it cannot
# get the lock then it waits for 10 seconds, and then tries
# again. It repeats this until the timeout has passed.
#
# We cannot log anything at this time, but we can use
# 'display' to display messages on the users screen.
#
RKHTMPVAR=0
while test $RKHTMPVAR -lt $LOCK_TIMEOUT; do
if [ -f "${RKHTMPDIR}/rkhunter.LCK" ]; then
test $SHOW_LOCK_MSGS -eq 1 -a $RKHTMPVAR -eq 0 && display --to SCREEN --type PLAIN --nonl LOCK_WAIT
sleep 10;
RKHTMPVAR=`expr ${RKHTMPVAR} + 10`
test $SHOW_LOCK_MSGS -eq 1 && display --to SCREEN --type PLAIN --nonl NAME "..${RKHTMPVAR}"
else
break
fi
done
if [ $RKHTMPVAR -lt $LOCK_TIMEOUT -o ! -f "${RKHTMPDIR}/rkhunter.LCK" ]; then
touch "${RKHTMPDIR}/rkhunter.LCK"
test $SHOW_LOCK_MSGS -eq 1 -a $RKHTMPVAR -gt 0 -a $NOTTY -eq 0 && echo ""
#
# We handle any subsequent exit conditions by setting a trap.
#
trap "rm -f \"${RKHTMPDIR}/rkhunter.LCK\" >/dev/null 2>&1" 0 >/dev/null 2>&1
else
#
# We need to be careful here. We do not want to display the message if the user
# has explicitly requested not to, but we must display it if the user has set
# the '--report-warnings-only' option (we treat it as a warning), or the
# '--cronjob' option. If we did not, then the user may think that rkhunter has
# run and that there were no warnings. If the user used the '--quiet' option,
# then this message won't be displayed. However, that is okay because they
# should be checking the return-code.
#
if [ $SHOWWARNINGSONLY -eq 1 -o $CRONJOB -eq 1 ]; then
NOTTY=0
RKHTMPVAR=""
else
RKHTMPVAR="--nl"
fi
test $SHOW_LOCK_MSGS -eq 1 -o $NOTTY -eq 0 && display --to SCREEN --type PLAIN ${RKHTMPVAR} LOCK_FAIL
exit 1
fi
return
}
help() {
#
# This function outputs the help menu.
#
echo $ECHOOPT ""
echo $ECHOOPT "Usage: rkhunter {--check | --unlock | --update | --versioncheck |"
echo $ECHOOPT " --propupd [{filename | directory | package name},...] |"
echo $ECHOOPT " --list [{tests | {lang | languages} | rootkits | perl | propfiles}] |"
echo $ECHOOPT " --config-check | --version | --help} [options]"
echo $ECHOOPT ""
echo $ECHOOPT "Current options are:"
echo $ECHOOPT " --append-log Append to the logfile, do not overwrite"
echo $ECHOOPT " --bindir <directory>... Use the specified command directories"
echo $ECHOOPT " -c, --check Check the local system"
echo $ECHOOPT " -C, --config-check Check the configuration file(s), then exit"
echo $ECHOOPT " --cs2, --color-set2 Use the second color set for output"
echo $ECHOOPT " --configfile <file> Use the specified configuration file"
echo $ECHOOPT " --cronjob Run as a cron job"
echo $ECHOOPT " (implies -c, --sk and --nocolors options)"
echo $ECHOOPT " --dbdir <directory> Use the specified database directory"
echo $ECHOOPT " --debug Debug mode"
echo $ECHOOPT " (Do not use unless asked to do so)"
echo $ECHOOPT " --disable <test>[,<test>...] Disable specific tests"
echo $ECHOOPT " (Default is to disable no tests)"
echo $ECHOOPT " --display-logfile Display the logfile at the end"
echo $ECHOOPT " --enable <test>[,<test>...] Enable specific tests"
echo $ECHOOPT " (Default is to enable all tests)"
echo $ECHOOPT " --hash {MD5 | SHA1 | SHA224 | SHA256 | SHA384 | SHA512 |"
echo $ECHOOPT " NONE | <command>} Use the specified file hash function"
echo $ECHOOPT " (Default is SHA1, then MD5)"
echo $ECHOOPT " -h, --help Display this help menu, then exit"
echo $ECHOOPT " --lang, --language <language> Specify the language to use"
echo $ECHOOPT " (Default is English)"
echo $ECHOOPT " --list [tests | languages | List the available test names, languages,"
echo $ECHOOPT " rootkits | perl | rootkit names, perl module status"
echo $ECHOOPT " propfiles] or file properties database, then exit"
echo $ECHOOPT " -l, --logfile [file] Write to a logfile"
echo $ECHOOPT " (Default is $DFLT_LOGFILE)"
echo $ECHOOPT " --noappend-log Do not append to the logfile, overwrite it"
echo $ECHOOPT " --nocf Do not use the configuration file entries"
echo $ECHOOPT " for disabled tests (only valid with --disable)"
echo $ECHOOPT " --nocolors Use black and white output"
echo $ECHOOPT " --nolog Do not write to a logfile"
echo $ECHOOPT "--nomow, --no-mail-on-warning Do not send a message if warnings occur"
echo $ECHOOPT " --ns, --nosummary Do not show the summary of check results"
echo $ECHOOPT " --novl, --no-verbose-logging No verbose logging"
echo $ECHOOPT " --pkgmgr {RPM | DPKG | BSD | Use the specified package manager to obtain or"
echo $ECHOOPT " SOLARIS | NONE} verify file property values. (Default is NONE)"
echo $ECHOOPT " --propupd [file | directory | Update the entire file properties database,"
echo $ECHOOPT " package]... or just for the specified entries"
echo $ECHOOPT " -q, --quiet Quiet mode (no output at all)"
echo $ECHOOPT " --rwo, --report-warnings-only Show only warning messages"
echo $ECHOOPT " --sk, --skip-keypress Don't wait for a keypress after each test"
echo $ECHOOPT " --summary Show the summary of system check results"
echo $ECHOOPT " (This is the default)"
echo $ECHOOPT " --syslog [facility.priority] Log the check start and finish times to syslog"
echo $ECHOOPT " (Default level is $SYSLOG_DFLT_PRIO)"
echo $ECHOOPT " --tmpdir <directory> Use the specified temporary directory"
echo $ECHOOPT " --unlock Unlock (remove) the lock file"
echo $ECHOOPT " --update Check for updates to database files"
echo $ECHOOPT " --vl, --verbose-logging Use verbose logging (on by default)"
echo $ECHOOPT " -V, --version Display the version number, then exit"
echo $ECHOOPT " --versioncheck Check for latest version of program"
echo $ECHOOPT " -x, --autox Automatically detect if X is in use"
echo $ECHOOPT " -X, --no-autox Do not automatically detect if X is in use"
echo $ECHOOPT ""
return
}
######################################################################
#
# Initialisation
#
######################################################################
#
# Unfortunately, for the Korn shell if we are debugging then
# we need to enable tracing in each of the functions.
#
if [ $DEBUG_OPT -eq 1 -a "${MYSHELL}" = "ksh" ]; then
RKHTMPVAR=`typeset +f`
for RKHTMPVAR2 in ${RKHTMPVAR}; do
typeset -ft ${RKHTMPVAR2}
done
fi
#
# We reset the SIGPIPE signal to its default
# to try and avoid any output write errors.
#
trap - 13 >/dev/null 2>&1
#
# Initialise the variables used throughout the program.
#
PROGRAM_NAME="Rootkit Hunter"
PROGRAM_version="1.4.2"
PROGRAM_copyright_owner="Michael Boelen"
PROGRAM_copyright="Copyright (c) 2003-2014, ${PROGRAM_copyright_owner}"
PROGRAM_blurb="
Currently under active development by the ${PROGRAM_NAME} project team.
Please review your rkhunter.conf before using.
Please review the documentation before posting bug reports or questions.
To report bugs, obtain updates, or provide patches or comments, please go to:
http://rkhunter.sourceforge.net
To ask questions about rkhunter, please use the rkhunter-users mailing list.
Note this is a moderated list: please subscribe before posting.
${PROGRAM_NAME} comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under the
terms of the GNU General Public License. See the LICENSE file for details.
"
PROGRAM_license="
${PROGRAM_NAME} ${PROGRAM_version}, ${PROGRAM_copyright}
${PROGRAM_blurb}
"
LEAVE=0
ERRCODE=0
# Set to run as a cron job.
CRONJOB=0
CHECK=0
# Set to display the logfile at the end.
CATLOGFILE=0
NOLOG=0
RKHLOGFILE=""
DFLT_LOGFILE="/var/log/rkhunter.log"
# Set to have the logfile appended to rather than overwritten.
APPEND_LOG=0
APPEND_OPT=0
# Set to have the logfile copied if there was an error.
COPY_LOG_ON_ERROR=0
# Set to have rkhunter start/finish messages, and warnings,
# logged to syslog. The priority/severity can be set on the
# command-line or in the configuration file.
USE_SYSLOG=""
SYSLOG_DFLT_PRIO="authpriv.notice"
# By default do not send a mail-on-warning message.
NOMOW=0
MAILONWARNING=""
HASH_FUNC=""
OLD_HASH_FUNC=""
PKGMGR=""
OLD_PKGMGR=""
OLD_ATTRUPD=""
HASH_OPT=0
SHA_SIZE=0
HASH_FLD_IDX=1
PROP_DIR_LIST=""
PROP_FILE_LIST=""
PROP_FILE_LIST_COUNT=0
PROP_FILE_LIST_TOTAL=0
PRELINKED=0
PRELINK_CMD=""
PRELINK_HASH=""
PKGMGR_MD5_HASH=""
MD5_CMD=""
EPOCH_DATE_CMD=""
PKGMGRNOVRFY=""
UPDATE=0
PROP_UPDATE=0
PROPUPD_OPT=""
VERSIONCHECK=0
# By default use coloured output.
COLORS=1
CLRSET2=0
# Are whitelisted results to be shown as white?
WLIST_IS_WHITE=0
# Set to automatically detect if X is in use, and
# hence use the second colour set.
AUTO_X_DTCT=0
AUTO_X_OPT=0
# Set to be quiet. No output, but the return code will be set.
QUIET=0
# Set to only show warnings.
SHOWWARNINGSONLY=0
# This will be set if the file properties hash value check
# or the file attributes check is to be performed.
HASH_CHECK_ENABLED=0
SKIP_HASH_MSG=0
# Users can reset this to a new temporary directory.
RKHTMPDIR=""
# Users can reset this to a new database directory.
DB_PATH=""
# Users can reset this to a new configuration file.
CONFIGFILE=""
# Users cannnot reset this. The local config file must
# be in the same directory as the main config file.
LOCALCONFIGFILE=""
# Users cannot reset this. The rkhunter.d directory must
# be in the same directory as the main config file.
LOCALCONFIGDIR=""
# Users cannot reset this. The rkhunter.d config files
# can only be stored in the local config directory.
LOCALCONFDIRCOUNT=0
LOCALCONFDIRFILES=""
# This will be set similar to the current root PATH. Users can
# include new command directories to use as well.
BINPATHS=""
DFLT_BINPATHS="/bin /usr/bin /sbin /usr/sbin /usr/local/bin /usr/local/sbin /usr/libexec /usr/local/libexec"
BINDIR_OPT=0
# This will be set if any of the command directories is a symbolic link.
BINISLINK=0
# Default 'id' command. Solaris may reset this.
ID_CMD="id"
# Set if we don't want to wait for a keypress after each test.
SKIP_KEY_PRESS=0
# Does 'grep' need an extra option to check binary files?
GREP_OPT=""
# Set the O/S type if necessary.
BSDOS=0
SUNOS=0
IRIXOS=0
MACOSX=0
LINUXOS=0
case "${OPERATING_SYSTEM}" in
Linux)
LINUXOS=1
;;
*BSD|DragonFly)
BSDOS=1
HASH_FLD_IDX=4
GREP_OPT="-a"
;;
SunOS)
SUNOS=1
;;
IRIX*)
IRIXOS=1
;;
Darwin)
MACOSX=1
;;
esac
# This will be set if the local host or O/S has changed in some way.
OS_CHANGED=0
# By default we want a warning if the O/S has changed.
WARN_ON_OS_CHANGE=1
# If set, then automatically perform a properties update if the O/S changes.
UPDT_ON_OS_CHANGE=0
# These SSH options can only be set in the configuration file.
ALLOW_SSH_PROT_V1=0
ALLOW_SSH_ROOT_USER=""
SSH_CONFIG_DIR=""
# These syslog options can only be set in the configuration file.
ALLOW_SYSLOG_REMOTE_LOGGING=0
SYSLOG_CONFIG_FILE=""
# Set check counters to be used by the summary.
ROOTKIT_COUNT=0
ROOTKIT_FAILED_COUNT=0
ROOTKIT_FAILED_NAMES=""
PROP_FAILED_COUNT=0
SUMMARY_PROP_REQCMDS=0
APPS_COUNT=0
APPS_TOTAL_COUNT=0
APPS_FAILED_COUNT=0
# Timers for the system check.
BEGINTIME=0
TOTAL_SCANTIME=""
# This will be set if a warning message is logged.
WARNING_COUNT=0
# Ksyms or kallsyms file used in some checks.
KSYMS_FILE=""
# Record for logging the command-line being used.
CMD_LINE="$0 $*"
# Create a spaced-separated PATH variable.
RKHROOTPATH=`echo ${PATH} | tr ':' ' '`
# List of commands used during RKH. If a command does not exist, then
# the code may use an alternative method.
CMDLIST="basename diff dirname file find ifconfig ip ipcs ldd lsattr lsmod lsof mktemp netstat perl pgrep ps pwd readlink stat strings"
# Commands that are required to exist for RKH to run. The absolutely
# required commands are tested early on using just the root PATH. Then
# BINDIR is checked, and finally the rest of the commands are then
# checked using the new PATH from BINDIR.
ABSOLUTELY_REQUIRED_CMDS="cut egrep grep sed tail tr"
REQCMDS="awk cat chmod chown cp cut date egrep grep head ls mv sed sort tail touch tr uname uniq wc"
# List of commands used to download files from the web. This list is
# used by the '--update' and '--versioncheck' options. Preferred commands
# are listed first. This can be overridden by the config file.
WEBCMDLIST="wget curl elinks links lynx bget GET"
RKHWEBCMD=""
RKHWEBCMD_OPTS=""
RKHWEBCMD_BASE=""
HOST_NAME=""
# This is the return code for the program actions - update, check, etc.
# Its value may either be 0 (no error) or 1 (an error occurred).
# The '--versioncheck' option may set the return code to 2 to
# indicate that an update is available.
# The '--update' option may set the return code to 2 to
# indicate that an update occurred.
RET_CODE=0
# Initially there is no language, this will be set later.
LANGUAGE=""
UPDATE_LANG=""
LOCALE_CMD=""
ICONV_CMD=""
RKHCHRMAP=""
RKHCHKLOCALE=0
# A space-separated list of test names we recognise.
KNOWN_TESTS="strings properties hashes scripts immutable attributes
deleted_files packet_cap_apps apps rootkits known_rkts
additional_rkts malware local_host network passwd_changes
group_changes possible_rkt_files possible_rkt_strings
system_commands shared_libs shared_libs_path running_procs
hidden_procs trojans other_malware os_specific startup_malware
startup_files group_accounts system_configs filesystem suspscan
ports hidden_ports promisc loaded_modules avail_modules"
# A space-separated list of test 'group names'. This list allows test
# names to be grouped together. For example, 'system_commands' can include
# the specific tests of 'strings' and 'hashes'. Both test
# group names, and specific test names, can be used with the test
# enable/disable options. In this list group names are colon-separated
# from the specific test names.
#
GROUPED_TESTS="system_commands:properties:strings:hashes:scripts:shared_libs:shared_libs_path:immutable:attributes
properties:hashes:scripts:immutable:attributes
shared_libs:shared_libs_path
rootkits:known_rkts:additional_rkts:possible_rkt_files:possible_rkt_strings:malware:running_procs:hidden_procs:deleted_files:trojans:other_malware:os_specific:suspscan:loaded_modules:avail_modules
additional_rkts:possible_rkt_files:possible_rkt_strings
network:packet_cap_apps:ports:hidden_ports:promisc
malware:running_procs:hidden_procs:deleted_files:suspscan:other_malware
local_host:startup_files:passwd_changes:group_changes:startup_malware:group_accounts:system_configs:filesystem
startup_files:startup_malware
os_specific:loaded_modules:avail_modules
group_accounts:passwd_changes:group_changes"
# A comma-separated list of rootkits we check for.
# NOTE: This is a COMMA separated list. Any single quotes need to be handled specially - i.e.
# put between double-quotes.
KNOWN_ROOTKITS='55808 Trojan - Variant A, AjaKit, aPa Kit, Adore, Apache Worm, Ambient (ark),
Balaur, BeastKit, beX2, BOBKit, Boonana (Koobface.A), cb, CiNIK Worm (Slapper.B variant), CX,
Danny-Boy'"'"'s Abuse Kit, Devil, Dica, Dreams, Duarawkz, Enye LKM, Flea Linux, FreeBSD, Fu,
Fuck`it, GasKit, Heroin LKM, HjC Kit, ignoKit, iLLogiC, Inqtana-A, Inqtana-B, Inqtana-C,
IntoXonia-NG, Irix, Jynx, KBeast, Kitko, Knark, ld-linuxv.so, Li0n Worm, Lockit/LJK2, Mood-NT, MRK, Ni0,
Ohhara, Optic Kit (Tux), OSXRK, Oz, Phalanx, Phalanx2, Portacelo, R3dstorm Toolkit,
RH-Sharpe'"'"'s, RSHA'"'"'s, Scalper Worm, Shutdown, SHV4, SHV5, Sin, SInAR, Slapper,
Sneakin, Solaris Wanuk, Spanish, Suckit, SunOS / NSDAP, SunOS Rootkit, Superkit, TBD (Telnet BackDoor),
TeLeKiT, Togroot, T0rn, trNkit, Trojanit Kit, Turtle2, Tuxtendo, URK, Vampire, VcKit, Volc, w00tkit,
weaponX, Xzibit, X-Org SunOS, zaRwT.KiT, ZK'
# A space-separated list of perl modules that may be required.
LIST_MODULES="File::stat Getopt::Long Crypt::RIPEMD160 Digest::MD5 Digest::SHA Digest::SHA1 Digest::SHA256
Digest::SHA::PurePerl Digest::Whirlpool LWP URI HTTP::Status HTTP::Date Socket Carp"
# A list of configuration options which are space-separated lists.
SPACE_LIST_OPTS="ALLOWPROMISCIF APP_WHITELIST BINDIR DISABLE_TESTS EMPTY_LOGFILES ENABLE_TESTS
IGNORE_PRELINK_DEP_ERR INETD_ALLOWED_SVC MAIL-ON-WARNING MISSING_LOGFILES
PORT_WHITELIST PWDLESS_ACCOUNTS SHARED_LIB_WHITELIST STARTUP_PATHS SUSPSCAN_DIRS
SYSLOG_CONFIG_FILE UID0_ACCOUNTS UNHIDE_TESTS UNHIDETCP_OPTS UPDATE_LANG
XINETD_ALLOWED_SVC"
SPACE_LIST_OPTS=" `echo ${SPACE_LIST_OPTS}` "
# A list of configuration options which are newline-separated lists.
NEWLINE_LIST_OPTS="ALLOWDEVFILE ALLOWHIDDENDIR ALLOWHIDDENFILE ALLOWPROCDELFILE ALLOWPROCLISTEN
ATTRWHITELIST EXCLUDE_USER_FILEPROP_FILES_DIRS EXISTWHITELIST IMMUTWHITELIST
PKGMGR_NO_VRFY PORT_PATH_WHITELIST RTKT_DIR_WHITELIST RTKT_FILE_WHITELIST
SCRIPTWHITELIST USER_FILEPROP_FILES_DIRS WRITEWHITELIST"
NEWLINE_LIST_OPTS=" `echo ${NEWLINE_LIST_OPTS}` "
# The program defaults of which tests to perform will be set later.
ENABLE_TESTS=""
DISABLE_TESTS=""
CL_ENABLE_TESTS=""
CL_DISABLE_TESTS=""
CONFIG_DISABLE_TESTS=""
# These get set if the '--enable' or '--disable' command-line options have been used.
ENDIS_OPT=0
ENABLE_OPT=0
# This gets set to zero if the '--nocf' command-line option is used.
USECF=1
# This gets set if the '--list' command-line option is used.
LIST_OPT=""
# Space-filled line used for the display function.
BLANK_LINE=" "
# Initially say that we are connected to a terminal.
NOTTY=0
# By default show the system check summary.
SHOW_SUMMARY=1
SHOW_SUMMARY_OPT=0
SHOW_SUMMARY_TIME=3
SHOW_SUMMARY_WARNINGS_NUMBER=0
# By default log most things that are checked.
VERBOSE_LOGGING=1
# We copy the original IFS value, and set RKHIFS to space, tab, newline.
# IFSNL is set to just a newline.
ORIGIFS=$IFS
RKHIFS="
"
IFSNL="
"
IFS=$RKHIFS
# No default set for the system startup files and directories.
STARTUP_PATHS=""
STARTUP_PATHS_LOGGED=0
# Set a default for the inetd configuration file.
INETD_CONF_PATH="/etc/inetd.conf"
INETDALLOWEDSVCS=""
# Set a default for the xinetd configuration file.
XINETD_CONF_PATH="/etc/xinetd.conf"
XINETDALLOWEDSVCS=""
# Set if only the '--update' option is used.
UPDATE_ONLY=0
# Set if UPDATE_ONLY is set, and some language files are missing.
RKHLANGUPDT=0
# By default we rotate the mirrors in the mirrors.dat file,
# and we update the file when the '--update' option is used.
# The default MIRRORS_MODE is set such that we use both local
# and remote mirrors.
ROTATE_MIRRORS=1
UPDATE_MIRRORS=1
MIRRORS_MODE=0
# By default suspscan verbose logging should be initialised and off.
SUSPSCAN_DEBUG=0
# SELinux runcon usage as determined by get_if_prelinked.
USE_RUNCON=0
SELINUX_ENABLED=0
# These get set if any network ports are to be whitelisted.
PORT_WHITELIST=""
PORT_PATH_WHITELIST=""
PORT_WHITELIST_ALL_TRUSTED=0
# This will be set to the shadow file location if required.
SHADOW_FILE=""
HAVE_TCB_SHADOW=0
# The O/S 'release' file location.
OS_VERSION_FILE=""
# By default no rootkit files or directories are whitelisted.
RTKT_DIR_WHITELIST=""
RTKT_FILE_WHITELIST=""
# The full pathname of the 'rkhunter.dat' file.
RKHDAT_FILE=""
# The full pathname of the 'rkhunter_prop_list.dat' file.
RKH_FILEPROP_LIST=""
# This gets set if we have a working readlink command.
HAVE_READLINK=0
# By default no commands are to be exempt from dependency errors.
PRELINK_DEP_ERR_CMDS=""
# User provided files/dirs for the file properties check.
USER_FILE_LIST=""
USER_SIMPLE_FILE_LIST=""
USER_DIR_LIST=""
USER_EXCLUDE_PROP=""
# This gets set if any shared libraries are to be whitelisted.
SHARED_LIB_WHITELIST=""
# If used, these lock values must be set in the config file.
USE_LOCKING=0
LOCK_TIMEOUT=0
SHOW_LOCK_MSGS=1
# This gets set if the '--unlock' command-line option is used.
UNLOCK=0
# This gets set if any files or directories need
# whitelisting from 'existence' checks.
EXISTWHITELIST=""
# This will be set if we are just doing a config file check.
CONFIG_CHECK=0
# Network interface whitelist.
IFWLIST=""
# This will be set to any allowed processes listening on the network.
ALLOWPROCLIST_OPT=""
######################################################################
#
# Command-line option processing
#
######################################################################
#
# Display the help menu if no options were given.
#
if [ $# -eq 0 ]; then
help
exit 0
fi
#
# Check the command-line options. If set, these will override the
# configuration file options.
#
while [ $# -ge 1 ]; do
case "$1" in
--append-log | --appendlog)
APPEND_LOG=1
APPEND_OPT=1
;;
--bindir)
RKHTMPVAR="$2"
case "${RKHTMPVAR}" in
"")
;;
-*)
RKHTMPVAR=""
;;
*)
shift
BINPATHS="${BINPATHS} ${RKHTMPVAR}"
BINDIR_OPT=1
;;
esac
if [ -z "${RKHTMPVAR}" ]; then
echo "No command directories specified with '--bindir' option."
exit 1
fi
;;
-c | --check | --checkall | --check-all)
CHECK=1
;;
-C | --config-check | --configcheck | --check-config | --checkconfig)
CONFIG_CHECK=1
;;
--configfile)
CONFIGFILE=""
case "$2" in
"")
;;
-*)
;;
*)
shift
CONFIGFILE="$1"
;;
esac
if [ -z "${CONFIGFILE}" ]; then
echo "No configuration file specified with '--configfile' option."
exit 1
fi
;;
--cronjob)
CHECK=1
CRONJOB=1
COLORS=0
SKIP_KEY_PRESS=1
;;
--cs2 | --colorset2 | --color-set2)
CLRSET2=1
;;
--dbdir)
DB_PATH=""
case "$2" in
"")
;;
-*)
;;
*)
shift
DB_PATH="$1"
;;
esac
if [ -z "${DB_PATH}" ]; then
echo "No database directory specified with '--dbdir' option."
exit 1
fi
;;
--debug)
SKIP_KEY_PRESS=1
;;
--display-logfile | --displaylogfile | --display-log | --displaylog | --showlog)
CATLOGFILE=1
;;
--disable)
RKHTMPVAR="$2"
case "${RKHTMPVAR}" in
"")
;;
-*)
RKHTMPVAR=""
;;
*)
shift
CHECK=1
ENDIS_OPT=1
CL_DISABLE_TESTS="${CL_DISABLE_TESTS} ${RKHTMPVAR}"
;;
esac
if [ -z "${RKHTMPVAR}" ]; then
echo "No tests specified with '--disable' option."
exit 1
fi
;;
--enable)
RKHTMPVAR="$2"
case "${RKHTMPVAR}" in
"")
;;
-*)
RKHTMPVAR=""
;;
*)
shift
CHECK=1
ENDIS_OPT=1
ENABLE_OPT=1
CL_ENABLE_TESTS="${CL_ENABLE_TESTS} ${RKHTMPVAR}"
;;
esac
if [ -z "${RKHTMPVAR}" ]; then
echo "No tests specified with '--enable' option."
exit 1
fi
;;
--hash)
HASH_FUNC=""
case "$2" in
"")
;;
-*)
;;
*)
shift
HASH_FUNC="$1"
HASH_OPT=1
;;
esac
if [ -z "${HASH_FUNC}" ]; then
echo "No hash function specified with '--hash' option."
exit 1
fi
;;
-h | --help)
help
exit 0
;;
-l | --log | --logfile | --createlogfile | --createlog | --create-log | --create-logfile)
RKHLOGFILE="${DFLT_LOGFILE}"
case "$2" in
"")
;;
-*)
;;
*)
shift
RKHLOGFILE="$1"
;;
esac
;;
--lang | --language)
LANGUAGE=""
case "$2" in
"")
;;
-*)
;;
*)
shift
LANGUAGE="$1"
;;
esac
if [ -z "${LANGUAGE}" ]; then
echo "No language specified with '$1' option."
exit 1
fi
;;
--list)
case "$2" in
test | tests | check | checks)
shift
LIST_OPT="${LIST_OPT} tests "
;;
lang | langs | language | languages)
shift
LIST_OPT="${LIST_OPT} languages "
;;
rootkit | rootkits)
shift
LIST_OPT="${LIST_OPT} rootkits "
;;
perl | modules)
shift
LIST_OPT="${LIST_OPT} perl "
;;
propfiles)
shift
LIST_OPT="${LIST_OPT} propfiles "
;;
"")
LIST_OPT="${LIST_OPT} tests languages rootkits perl "
;;
*)
echo "Invalid '--list' option specified: $2"
exit 1
;;
esac
;;
--noappend-log | --no-append-log | --noappendlog)
APPEND_LOG=0
APPEND_OPT=1
;;
--nocf)
USECF=0
;;
--nocolors | --no-colors | --nocolor | --no-color)
COLORS=0
;;
--nolog | --no-log)
RKHLOGFILE="/dev/null"
;;
--nomow | --no-mow | --no-mailonwarning | --no-mail-on-warning)
NOMOW=1
;;
--novl | --noverboselogging | --no-verbose-logging)
VERBOSE_LOGGING=0
;;
--ns | --nosummary | --no-summary)
SHOW_SUMMARY=0
SHOW_SUMMARY_OPT=1
;;
--pkgmgr)
PKGMGR=""
case "$2" in
"")
;;
-*)
;;
*)
shift
PKGMGR="$1"
;;
esac
if [ -z "${PKGMGR}" ]; then
echo "No package manager specified with '--pkgmgr' option."
exit 1
fi
;;
--propupd | --prop-update | --propupdate | --properties-update | --hashupd)
PROP_UPDATE=1
PROPUPD_OPT=""
case "$2" in
"")
;;
-*)
;;
*)
shift
PROPUPD_OPT="$1"
;;
esac
;;
-q | --quiet)
QUIET=1
;;
--rwo | --swo | --report-warnings-only | --show-warnings-only)
QUIET=1
SHOWWARNINGSONLY=1
;;
-r | --rootdir)
echo "The '$1' option is now deprecated."
shift
;;
-sk | --sk | --skip-keypress | --skipkeypress)
SKIP_KEY_PRESS=1
;;
--summary)
SHOW_SUMMARY=1
SHOW_SUMMARY_OPT=1
;;
--syslog)
USE_SYSLOG="${SYSLOG_DFLT_PRIO}"
case "$2" in
"")
;;
-*)
;;
*)
shift
USE_SYSLOG="$1"
;;
esac
;;
--tmpdir)
RKHTMPDIR=""
case "$2" in
"")
;;
-*)
;;
*)
shift
RKHTMPDIR="$1"
;;
esac
if [ -z "${RKHTMPDIR}" ]; then
echo "No temporary directory specified with '--tmpdir' option."
exit 1
fi
;;
--unlock)
UNLOCK=1
;;
--update)
UPDATE=1
;;
--vl | --verboselogging | --verbose-logging)
VERBOSE_LOGGING=1
;;
-V | --version)
echo "${PROGRAM_NAME} ${PROGRAM_version}"
echo "${PROGRAM_blurb}"
exit 0
;;
--versioncheck | --version-check)
VERSIONCHECK=1
;;
-x | --autox)
AUTO_X_OPT=1
AUTO_X_DTCT=1
;;
-X | --no-autox)
AUTO_X_OPT=1
AUTO_X_DTCT=0
;;
*)
echo "Invalid option specified: $1"
exit 1
;;
esac
shift
done
#
# We check that we are root. If we are not, then only the
# help and version command-line options are valid.
#
if [ $SUNOS -eq 1 ]; then
test -x /usr/xpg4/bin/id && ID_CMD="/usr/xpg4/bin/id"
fi
RKHTMPVAR=`${ID_CMD} -u 2>/dev/null`
if [ -z "${RKHTMPVAR}" ]; then
RKHTMPVAR=`whoami 2>/dev/null`
if [ -z "${RKHTMPVAR}" ]; then
RKHTMPVAR=`who am i 2>/dev/null | cut -d' ' -f1`
if [ -z "${RKHTMPVAR}" ]; then
RKHTMPVAR=`who -m 2>/dev/null | cut -d' ' -f1`
fi
fi
fi
if [ -z "${RKHTMPVAR}" ]; then
echo "Unable to determine if you are root."
exit 1
elif [ "${RKHTMPVAR}" != "0" -a "${RKHTMPVAR}" != "root" ]; then
echo "You must be the root user to run this program."
exit 1
fi
#
# We need to see if we are to run a check before we get to the
# configuration file processing code. Basically if either of the
# '--enable' or '--disable' options are used, then we will do a
# check.
#
if [ $ENDIS_OPT -eq 1 ]; then
CL_ENABLE_TESTS=`echo ${CL_ENABLE_TESTS}`
CL_DISABLE_TESTS=`echo ${CL_DISABLE_TESTS}`
# The '--nocf' option is only for disabled tests.
test -z "${CL_DISABLE_TESTS}" && USECF=1
else
USECF=1
fi
#
# See if only the '--update' option has been used.
#
test $UPDATE -eq 1 -a $CHECK -eq 0 -a $PROP_UPDATE -eq 0 -a $VERSIONCHECK -eq 0 && UPDATE_ONLY=1
#
# Before going too much further we need to ensure that some basic
# commands are present on the system. We cannot do this using
# the BINDIR option because that requires processing the configuration
# file, which in turn requires the commands we want to check on. As
# such we use the default command directory list. We do not assign
# these commands to variables, but will do for other commands which we
# look for later on.
#
check_required_commands 1
######################################################################
#
# Configuration file processing
#
######################################################################
#
# Now we check for the configuration file. We then see if there is a
# local configuration file present in the same directory, and finally
# check the various options within them.
#
# NOTE: Do not change the format of the following 'if' statement.
# The installer script will modify it directly during installation.
#
if [ -z "${CONFIGFILE}" ]; then
if [ -f /etc/rkhunter.conf ]; then
CONFIGFILE="/etc/rkhunter.conf"
else
CONFIGFILE="/usr/local/etc/rkhunter.conf"
fi
fi
if [ ! -f "${CONFIGFILE}" ]; then
echo "Unable to find configuration file: ${CONFIGFILE}"
exit 1
elif [ ! -r "${CONFIGFILE}" ]; then
echo "Configuration file is not readable: ${CONFIGFILE}"
exit 1
elif [ ! -s "${CONFIGFILE}" ]; then
echo "Configuration file is empty: ${CONFIGFILE}"
exit 1
fi
RKHTMPVAR=`echo "${CONFIGFILE}" | sed -e 's:/[^/]*$::'`
test -f "${RKHTMPVAR}/rkhunter.conf.local" -a ! -h "${RKHTMPVAR}/rkhunter.conf.local" -a -r "${RKHTMPVAR}/rkhunter.conf.local" && LOCALCONFIGFILE="${RKHTMPVAR}/rkhunter.conf.local"
if [ -d "${RKHTMPVAR}/rkhunter.d" ]; then
LOCALCONFIGDIR="${RKHTMPVAR}/rkhunter.d"
for FNAME in ${LOCALCONFIGDIR}/*.conf; do
test ! -f "${FNAME}" -o -h "${FNAME}" -o ! -r "${FNAME}" && continue
LOCALCONFDIRCOUNT=`expr ${LOCALCONFDIRCOUNT} + 1`
LOCALCONFDIRFILES="${LOCALCONFDIRFILES} ${FNAME}"
done
fi
get_configfile_options
#
# If we are doing a configuration file
# check, then this is as far as we go.
#
if [ $CONFIG_CHECK -eq 1 ]; then
do_config_file_check
exit $RET_CODE
fi
######################################################################
#
# Option processing
#
######################################################################
#
# Next we check some of the options to make sure we can proceed. We
# also set up some final variables based on the combination of options
# we have been given.
#
#
# First we process the '--list' option if it has been given.
#
if [ -n "${LIST_OPT}" ]; then
for RKHTMPVAR in ${LIST_OPT}; do
case "${RKHTMPVAR}" in
tests)
display_tests
;;
languages)
display_languages
;;
perl)
display_perl_modules
;;
propfiles)
display_propfiles
;;
*)
display_rootkits
;;
esac
done
exit 0
fi
#
# Next we must see if we are doing an update only, and if there were
# some language file problems. If so, then we must not log or display
# anything.
#
if [ $RKHLANGUPDT -eq 1 ]; then
QUIET=1
COLORS=0
RKHLOGFILE="/dev/null"
fi
#
# If the logfile has been disabled, then we cannot let the
# program run when certain options are used. If we did, the user
# would see no output and might assume that all was well.
#
if [ "${RKHLOGFILE}" = "/dev/null" ]; then
NOLOG=1
VERBOSE_LOGGING=0
COPY_LOG_ON_ERROR=0
if [ $SHOWWARNINGSONLY -eq 1 ]; then
echo "The logfile has been disabled - unable to report warnings."
exit 1
elif [ $CATLOGFILE -eq 1 ]; then
echo "The logfile has been disabled - unable to display the log file."
exit 1
fi
fi
#
# Set up the colors to be used.
#
if [ $COLORS -eq 1 ]; then
NORMAL="[0;39m" # Foreground colour to default
if [ $CLRSET2 -eq 0 ]; then
RED="[1;31m" # Bright red
GREEN="[1;32m" # Bright green
YELLOW="[1;33m" # Bright yellow
WHITE="[1;37m" # White
else
RED="[1;31m" # Bright red
GREEN="[0;32m" # Green
YELLOW="[0;35m" # Purple
WHITE="[0;30m" # Black
fi
fi
if [ $CHECK -eq 1 ]; then
#
# Check if we have a ksyms or kallsyms file.
#
if [ -f "/proc/ksyms" ]; then
KSYMS_FILE="/proc/ksyms"
elif [ -f "/proc/kallsyms" ]; then
KSYMS_FILE="/proc/kallsyms"
fi
#
# Check to make sure that the symbols are readable
# as certain security frameworks hide this.
#
if [ -z "`head ${HEAD_OPT}1 /proc/kallsyms 2>/dev/null`" ]; then
KSYMS_FILE=""
fi
fi
if [ $CHECK -eq 1 -o $PROP_UPDATE -eq 1 ]; then
if [ -e "${RKHDAT_FILE}" ]; then
if [ -h "${RKHDAT_FILE}" ]; then
echo "The rkhunter.dat file is a symbolic link: ${RKHDAT_FILE}"
echo "This is a security problem. The link points to another file, and that file may be modified by rkhunter."
exit 1
elif [ ! -f "${RKHDAT_FILE}" ]; then
echo "The rkhunter.dat file is not a file: ${RKHDAT_FILE}"
exit 1
fi
fi
if [ -e "${RKH_FILEPROP_LIST}" ]; then
if [ -h "${RKH_FILEPROP_LIST}" ]; then
echo "The rkhunter_prop_list.dat file is a symbolic link: ${RKH_FILEPROP_LIST}"
echo "This is a security problem. The link points to another file, and that file may be modified by rkhunter."
exit 1
elif [ ! -f "${RKH_FILEPROP_LIST}" ]; then
echo "The rkhunter_prop_list.dat file is not a file: ${RKH_FILEPROP_LIST}"
exit 1
fi
fi
#
# Check if the file properties option has been set. If so, then
# check that the files and directories are valid. Once that has
# been done, we can then set up the file properties check directories
# and file names.
#
if [ -n "${PROPUPD_OPT}" ]; then
if [ ! -f "${RKHDAT_FILE}" ]; then
echo "The file properties file does not exist: ${RKHDAT_FILE}"
exit 1
fi
#
# We need the current 'rkhunter.dat' file format.
#
FMTVERSION=`grep '^FormatVersion:' "${RKHDAT_FILE}" | cut -d: -f2`
test -z "${FMTVERSION}" && FMTVERSION=0
LEAVE=0
RKHTMPVAR=""
PROPUPD_OPT=`echo "${PROPUPD_OPT}" | tr ',' "\n" | sed -e '/^$/d'`
test "${PROPUPD_OPT}" = "/" && PROPUPD_OPT=""
IFS=$IFSNL
for FNAME in ${PROPUPD_OPT}; do
if [ -n "`echo \"${FNAME}\" | grep '^[^/].*/'`" ]; then
# Filename is relative
LEAVE=1
echo "Relative file or directory name specified: ${FNAME}"
elif [ -n "`echo \"${FNAME}\" | grep '^/'`" ]; then
# Filename is absolute
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ $FMTVERSION -eq 0 ]; then
RKHTMPVAR2=`grep "^File:${FNAMEGREP}:" "${RKHDAT_FILE}" 2>/dev/null | cut -d: -f2`
else
COLON_COUNT=`echo "${FNAME}" | tr -c -d ':' | wc -c | tr -d ' '`
RKHTMPVAR2=`grep "^File:${COLON_COUNT}:${FNAMEGREP}:" "${RKHDAT_FILE}" 2>/dev/null`
test -n "${RKHTMPVAR2}" && RKHTMPVAR2="${FNAME}"
fi
if [ -z "${RKHTMPVAR2}" ]; then
if [ -d "${FNAME}" ]; then
# Filename is a directory
if [ $FMTVERSION -eq 0 ]; then
RKHTMPVAR2=`grep "^File:${FNAMEGREP}/[^:]*:" "${RKHDAT_FILE}" 2>/dev/null | cut -d: -f2`
else
PATHS=""
IFS=$IFSNL
for RKHLINE in `grep "^File:[0-9]*:${FNAMEGREP}/" "${RKHDAT_FILE}"`; do
COLON_COUNT=`echo "${RKHLINE}" | cut -d: -f2`
COLON_COUNT=`expr 3 + $COLON_COUNT`
PATHNAME=`echo "${RKHLINE}" | cut -d: -f3-$COLON_COUNT`
PATHS="${PATHS}
${PATHNAME}"
done
IFS=$RKHIFS
RKHTMPVAR2=`echo "${PATHS}" | sed -e '/^$/d'`
fi
if [ -n "${RKHTMPVAR2}" ]; then
RKHTMPVAR="${RKHTMPVAR}
${RKHTMPVAR2}"
else
LEAVE=1
echo "Directory is not in the \"rkhunter.dat\" file: ${FNAME}"
fi
else
LEAVE=1
echo "Filename is not in the \"rkhunter.dat\" file: ${FNAME}"
fi
else
RKHTMPVAR="${RKHTMPVAR}
${RKHTMPVAR2}"
fi
else
#
# Filename could be a package name.
# The package names are currently in field 11 in the 'rkhunter.dat' file.
#
FNAMEGREP=`echo "${FNAME}" | sed -e 's/\([.$*?\\]\)/\\\\\1/g; s/\[/\\\\[/g; s/\]/\\\\]/g'`
if [ $FMTVERSION -eq 0 ]; then
RKHTMPVAR2=`grep "^File:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:${FNAMEGREP}:" "${RKHDAT_FILE}" 2>/dev/null | cut -d: -f2`
else
PATHS=""
IFS=$IFSNL
for RKHLINE in `grep "^File:[0-9]*:.*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:${FNAMEGREP}:" "${RKHDAT_FILE}"`; do
COLON_COUNT=`echo "${RKHLINE}" | cut -d: -f2`
COLON_COUNT=`expr 3 + $COLON_COUNT`
PATHNAME=`echo "${RKHLINE}" | cut -d: -f3-$COLON_COUNT`
PATHS="${PATHS}
${PATHNAME}"
done
IFS=$RKHIFS
RKHTMPVAR2=`echo "${PATHS}" | sed -e '/^$/d'`
fi
if [ -z "${RKHTMPVAR2}" ]; then
# Filename is just a plain filename
if [ $FMTVERSION -eq 0 ]; then
RKHTMPVAR2=`grep "^File:[^:]*/${FNAMEGREP}:" "${RKHDAT_FILE}" 2>/dev/null | cut -d: -f2`
else
PATHS=""
IFS=$IFSNL
for RKHLINE in `grep "^File:[0-9]*:.*/${FNAMEGREP}:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:" "${RKHDAT_FILE}"`; do
COLON_COUNT=`echo "${RKHLINE}" | cut -d: -f2`
COLON_COUNT=`expr 3 + $COLON_COUNT`
PATHNAME=`echo "${RKHLINE}" | cut -d: -f3-$COLON_COUNT`
PATHS="${PATHS}
${PATHNAME}"
done
IFS=$RKHIFS
RKHTMPVAR2=`echo "${PATHS}" | sed -e '/^$/d'`
fi
if [ -n "${RKHTMPVAR2}" ]; then
RKHTMPVAR="${RKHTMPVAR}
${RKHTMPVAR2}"
else
LEAVE=1
echo "File or package name is not in the \"rkhunter.dat\" file: ${FNAME}"
fi
else
RKHTMPVAR="${RKHTMPVAR}
${RKHTMPVAR2}"
fi
fi
done
IFS=$RKHIFS
if [ $LEAVE -eq 0 ]; then
PROPUPD_OPT=`echo "${RKHTMPVAR}" | sed -e '/^$/d'`
else
exit 1
fi
fi
if `check_test properties` || test $PROP_UPDATE -eq 1; then
set_file_prop_dirs_files
fi
#
# We need to record the previously used
# hash function and package manager.
#
get_old_prop_attrs "${RKHDAT_FILE}"
fi
if [ $PROP_UPDATE -eq 1 -a $PRELINKED -eq 1 -a -z "${PKGMGR}" -a "${HASH_FUNC}" != "NONE" ]; then
#
# For a hash update on a prelinked system, we must have
# a valid hash function to use. The package managers use
# an MD5 hash function by default.
#
if [ -z "${PRELINK_HASH}" ]; then
if [ -z "`echo \"${HASH_FUNC}\" | egrep '(/filehashsha\.pl Digest::MD5|/filehashsha\.pl .* 1$|shasum -a 1$)'`" ]; then
RKHTMPVAR=`echo "${HASH_FUNC}" | cut -d' ' -f1`
if [ -z "`echo ${RKHTMPVAR} | egrep -i 'sha1|md5'`" ]; then
if [ $HASH_OPT -eq 1 ]; then
echo "This system uses prelinking, but the '--hash' option (${HASH_FUNC}) does not look like SHA1 or MD5."
else
echo "This system uses prelinking, but the hash function (${HASH_FUNC}) does not look like SHA1 or MD5."
fi
exit 1
fi
fi
fi
fi
#
# For the update and versioncheck options, we need to make sure
# we have a command capable of downloading files from the web.
# The first command found is used, unless it has been set in
# the configuration file.
#
if [ $UPDATE -eq 1 -o $VERSIONCHECK -eq 1 ]; then
if [ -z "${RKHWEBCMD}" ]; then
FOUND=0
for CMD in ${WEBCMDLIST}; do
#
# Ignore perl commands if perl is not present, or if
# certain modules are not present.
#
if [ "${CMD}" = "GET" ]; then
test -z "${PERL_CMD}" && continue
RKHTMPVAR=`${PERL_CMD} "${SCRIPT_PATH}/check_modules.pl" LWP URI HTTP::Status HTTP::Date Getopt::Long 2>&1 | grep 'NOT'`
test -n "${RKHTMPVAR}" && continue
elif [ "${CMD}" = "bget" ]; then
test -z "${PERL_CMD}" && continue
RKHTMPVAR=`${PERL_CMD} "${SCRIPT_PATH}/check_modules.pl" Socket Carp 2>&1 | grep 'NOT'`
test -n "${RKHTMPVAR}" && continue
fi
RKHTMPVAR=`find_cmd ${CMD}`
if [ -n "${RKHTMPVAR}" ]; then
FOUND=1
RKHWEBCMD="${RKHTMPVAR}"
RKHWEBCMD_BASE="${CMD}"
break
fi
done
if [ $FOUND -eq 0 ]; then
echo "The '--update' and '--versioncheck' options require a command able to"
echo "download files from the web. No such command can be found on the system."
echo "Examples of commands that could be used are: ${WEBCMDLIST}"
exit 1
fi
fi
fi
#
# If no option is given for the program to action, then say so and exit.
#
if [ $CHECK -eq 0 -a $VERSIONCHECK -eq 0 -a $UPDATE -eq 0 -a $PROP_UPDATE -eq 0 -a $UNLOCK -eq 0 ]; then
echo "You must enter an option for the program to perform."
echo "Type in 'rkhunter --help' to see the available options,"
echo "or read the rkhunter man page."
exit 1
fi
#
# Handle any locking straight away.
#
if [ $UNLOCK -eq 1 ]; then
rm -f "${RKHTMPDIR}/rkhunter.LCK" >/dev/null 2>&1
# If we are just unlocking the lock file, then exit.
test $CHECK -eq 0 -a $VERSIONCHECK -eq 0 -a $UPDATE -eq 0 -a $PROP_UPDATE -eq 0 && exit 0
fi
#
# Before writing anything to the screen or log file, we need to
# set some variables.
#
# First we set whether we should be displaying anything on the
# screen or not.
#
test $CRONJOB -eq 1 -o $QUIET -eq 1 && NOTTY=1
#
# Next we get the message types and results from the language file,
# and set them to variables. We have to look in the English file since
# that is the definitive one. We then look for the corresponding keyword
# in the actual language file. This allows the language files to work
# even if we add or remove any of the TYPE or RESULT keywords.
#
IFS=$IFSNL
for LINE in `egrep '^MSG_(TYPE|RESULT)_' "${DB_PATH}/i18n/en" 2>/dev/null`; do
TYPE=`echo "${LINE}" | cut -d: -f1`
if [ "${LANGUAGE}" != "en" ]; then
RKHTMPVAR=`grep ${GREP_OPT} "^${TYPE}:" "${DB_PATH}/i18n/${LANGUAGE}" 2>/dev/null`
test -n "${RKHTMPVAR}" && LINE=`echo "${RKHTMPVAR}" | sed -e 's/\`/\\\\\`/g'`
fi
RKHTMPVAR=`echo "${LINE}" | cut -d: -f2-`
eval $TYPE=\"${RKHTMPVAR}\"
done
IFS=$RKHIFS
#
# Before we touch the log file we must see if locking is being used.
#
if [ $USE_LOCKING -eq 1 ]; then
get_lock
fi
#
# Sort out the logfile before we write to it.
#
if [ $NOLOG -eq 0 ]; then
if [ $APPEND_LOG -eq 0 ]; then
if [ -f "${RKHLOGFILE}" ]; then
cp -f -p "${RKHLOGFILE}" "${RKHLOGFILE}.old" >/dev/null 2>&1
# Overwrite the log file with a null string.
if [ "${ECHON}" = "c" ]; then
echo $ECHOOPT "\c" >"${RKHLOGFILE}"
else
echo $ECHON $ECHOOPT "" >"${RKHLOGFILE}"
fi
else
# Create a new log file.
touch "${RKHLOGFILE}" >/dev/null 2>&1
chmod 600 "${RKHLOGFILE}" >/dev/null 2>&1
fi
else
if [ ! -f "${RKHLOGFILE}" ]; then
# Create a new log file.
touch "${RKHLOGFILE}" >/dev/null 2>&1
chmod 600 "${RKHLOGFILE}" >/dev/null 2>&1
fi
echo "" >>"${RKHLOGFILE}"
echo "" >>"${RKHLOGFILE}"
fi
fi
#
# Record the hostname. This will be used at several points
# throughout the program. A specific test will specify if
# a hostname has been found or not, so we don't need to
# do anything special here.
#
HOST_NAME=`hostname 2>/dev/null`
test -z "${HOST_NAME}" && HOST_NAME=`uname -n 2>/dev/null`
test -z "${HOST_NAME}" && HOST_NAME="${HOSTNAME}"
HOST_NAME=`echo ${HOST_NAME} | cut -d. -f1`
######################################################################
#
# Initial logging
#
######################################################################
#
# Write out various information messages to the logfile. The first
# set of messages can be skipped if no logfile is to be created.
#
display --to SCREEN --type PLAIN VERSIONLINE "${PROGRAM_NAME}" "${PROGRAM_version}"
if [ $NOLOG -eq 0 ]; then
if [ -n "${HOST_NAME}" ]; then
display --to LOG --type PLAIN VERSIONLINE2 "${PROGRAM_NAME}" "${PROGRAM_version}" "${HOST_NAME}"
else
display --to LOG --type PLAIN VERSIONLINE3 "${PROGRAM_NAME}" "${PROGRAM_version}"
fi
display --to LOG --type INFO --nl RKH_STARTDATE "`date`"
display --to LOG --type PLAIN --nl CONFIG_CHECK_START
display --to LOG --type INFO OPSYS "${OPERATING_SYSTEM}"
if [ -s "${RKHDAT_FILE}" ]; then
RKHTMPVAR=`grep '^OS:' "${RKHDAT_FILE}" 2>/dev/null | sed -e 's/^OS://'`
if [ -n "${RKHTMPVAR}" ]; then
display --to LOG --type INFO PROPUPD_OSNAME_FOUND "${RKHTMPVAR}"
else
display --to LOG --type INFO UNAME "`uname -a`"
fi
else
display --to LOG --type INFO UNAME "`uname -a`"
fi
display --to LOG --type INFO CONFIG_CMDLINE "${CMD_LINE}"
test $DEBUG_OPT -eq 1 && display --to LOG --type INFO CONFIG_DEBUGFILE "${RKHDEBUGFILE}"
display --to LOG --type INFO CONFIG_ENVSHELL "${SHELL}" "${MYSHELL}"
display --to LOG --type INFO CONFIG_CONFIGFILE "${CONFIGFILE}"
test -n "${LOCALCONFIGFILE}" && display --to LOG --type INFO CONFIG_LOCALCONFIGFILE "${LOCALCONFIGFILE}"
if [ -n "${LOCALCONFIGDIR}" ]; then
test $LOCALCONFDIRCOUNT -eq 1 && RKHTMPVAR="" || RKHTMPVAR="s"
display --to LOG --type INFO CONFIG_LOCALCONFIGDIR "${LOCALCONFIGDIR}" $LOCALCONFDIRCOUNT "${RKHTMPVAR}"
fi
display --to LOG --type INFO CONFIG_INSTALLDIR "${RKHINSTALLDIR}"
display --to LOG --type INFO CONFIG_LANGUAGE "${LANGUAGE}"
display --to LOG --type INFO CONFIG_DBDIR "${DB_PATH}"
display --to LOG --type INFO CONFIG_SCRIPTDIR "${SCRIPT_PATH}"
display --to LOG --type INFO CONFIG_BINDIR "${BINPATHS}"
display --to LOG --type INFO CONFIG_TMPDIR "${RKHTMPDIR}"
if [ $CHECK -eq 1 ]; then
if [ $NOMOW -eq 1 ]; then
display --to LOG --type INFO CONFIG_MOW_DISABLED
elif [ -z "${MAILONWARNING}" ]; then
display --to LOG --type INFO CONFIG_NO_MAIL_ON_WARN
else
display --to LOG --type INFO CONFIG_MAIL_ON_WARN "${MAILONWARNING}" "${MAIL_CMD}"
fi
fi
test $AUTO_X_DTCT -eq 1 && display --to LOG --type INFO CONFIG_X_AUTO
test $CLRSET2 -eq 1 && display --to LOG --type INFO CONFIG_CLRSET2
for CMD in ${CMDLIST}; do
RKHTMPVAR=`echo ${CMD} | tr '[:lower:]' '[:upper:]'`
RKHTMPVAR=`eval echo "\\$${RKHTMPVAR}_CMD"`
if [ -n "${RKHTMPVAR}" ]; then
display --to LOG --type INFO FOUND_CMD "${CMD}" "${RKHTMPVAR}"
else
display --to LOG --type INFO NOT_FOUND_CMD "${CMD}"
fi
done
test -n "${RKHWEBCMD}" && display --to LOG --type INFO FOUND_CMD "${RKHWEBCMD_BASE}" "${RKHWEBCMD}"
fi
if [ $PROP_UPDATE -eq 1 -o $HASH_CHECK_ENABLED -eq 1 ]; then
if [ -z "${PKGMGR}" -a "${HASH_FUNC}" = "NONE" ]; then
HASH_CHECK_ENABLED=0
DISABLE_TESTS="${DISABLE_TESTS} hashes"
display --to LOG --type INFO HASH_FUNC_DISABLED
fi
if [ $PRELINKED -eq 1 ]; then
display --to LOG --type INFO SYS_PRELINK
display --to LOG --type INFO FOUND_CMD 'prelink' "${PRELINK_CMD}"
if [ -n "${SESTATUS_CMD}" ]; then
display --to LOG --type INFO FOUND_CMD 'sestatus' "${SESTATUS_CMD}"
if [ $SELINUX_ENABLED -eq 1 ]; then
display --to LOG --type INFO SYS_SELINUX
if [ $USE_RUNCON -eq 1 ]; then
display --to LOG --type INFO FOUND_CMD 'runcon' "${RUNCON_CMD}"
else
display --to LOG --type INFO NOT_FOUND_CMD 'runcon'
fi
else
display --to LOG --type INFO SYS_NO_SELINUX
fi
else
display --to LOG --type INFO NOT_FOUND_CMD 'sestatus'
fi
if [ "${HASH_FUNC}" = "NONE" ]; then
if [ -n "${PKGMGR}" ]; then
display --to LOG --type INFO HASH_FUNC_NONE_PKGMGR
else
display --to LOG --type INFO HASH_FUNC_NONE
fi
elif [ -n "${PRELINK_HASH}" ]; then
display --to LOG --type INFO HASH_FUNC_PRELINK "${PRELINK_HASH}"
elif [ -z "`echo \"${HASH_FUNC}\" | egrep -i 'sha1|md5'`" ]; then
SKIP_HASH_MSG=1
else
display --to LOG --type INFO HASH_FUNC "${HASH_FUNC}"
fi
else
display --to LOG --type INFO SYS_NO_PRELINK
if [ "${HASH_FUNC}" = "NONE" ]; then
if [ -n "${PKGMGR}" ]; then
display --to LOG --type INFO HASH_FUNC_NONE_PKGMGR
else
display --to LOG --type INFO HASH_FUNC_NONE
fi
elif [ -n "`echo \"${HASH_FUNC}\" | grep '/filehashsha\.pl '`" ]; then
RKHTMPVAR=`echo "${HASH_FUNC}" | cut -d' ' -f3`
if [ $SHA_SIZE -eq 0 ]; then
display --to LOG --type INFO HASH_FUNC_PERL "${RKHTMPVAR}"
else
display --to LOG --type INFO HASH_FUNC_PERL_SHA "${RKHTMPVAR}" "SHA${SHA_SIZE}"
fi
else
display --to LOG --type INFO HASH_FUNC "${HASH_FUNC}"
fi
fi
if [ -s "${RKHDAT_FILE}" ]; then
if [ "${OLD_HASH_FUNC}" = "Disabled" ]; then
display --to LOG --type INFO HASH_FUNC_OLD_DISABLED
else
display --to LOG --type INFO HASH_FUNC_OLD "${OLD_HASH_FUNC}"
fi
if [ -z "${OLD_PKGMGR}" ]; then
display --to LOG --type INFO HASH_PKGMGR_OLD_UNSET
else
display --to LOG --type INFO HASH_PKGMGR_OLD "${OLD_PKGMGR}"
fi
fi
display --to LOG --type INFO HASH_FIELD_INDEX "$HASH_FLD_IDX"
if [ $PROP_UPDATE -eq 1 ]; then
if ! `check_test hashes` && test $ENDIS_OPT -eq 0; then
display --to LOG --type INFO HASHUPD_DISABLED
elif [ -z "${PKGMGR}" ]; then
if [ $PRELINKED -eq 1 ]; then
if [ -n "${PRELINK_HASH}" ]; then
display --to LOG --type INFO HASHUPD_PKGMGR_NOT_SPEC_PRELINKED "${PRELINK_HASH}"
else
display --to LOG --type INFO HASHUPD_PKGMGR_NOT_SPEC "${HASH_FUNC}"
fi
else
display --to LOG --type INFO HASHUPD_PKGMGR_NOT_SPEC "${HASH_FUNC}"
fi
else
display --to LOG --type INFO HASHUPD_PKGMGR "${PKGMGR}"
case "${PKGMGR}" in
RPM)
display --to LOG --type INFO FOUND_CMD 'rpm' "${RPM_CMD}"
;;
DPKG)
if [ -z "`echo \"${DPKG_CMD}\" | grep '/dpkg$'`" ]; then
display --to LOG --type INFO FOUND_CMD 'dpkg-query' "${DPKG_CMD}"
else
display --to LOG --type INFO FOUND_CMD 'dpkg' "${DPKG_CMD}"
fi
;;
BSD)
display --to LOG --type INFO FOUND_CMD 'pkg-info' "${PKG_CMD}"
;;
SOLARIS)
if [ $USE_SUNSUM -eq 1 ]; then
display --to LOG --type INFO HASH_PKGMGR_SUM
display --to LOG --type INFO FOUND_CMD 'sum' "${SUM_CMD}"
fi
;;
esac
fi
fi
if [ $HASH_CHECK_ENABLED -eq 1 ]; then
if [ -z "${PKGMGR}" ]; then
if [ $PRELINKED -eq 1 ]; then
if [ -n "${PRELINK_HASH}" ]; then
display --to LOG --type INFO HASH_PKGMGR_NOT_SPEC_PRELINKED "${PRELINK_HASH}"
else
display --to LOG --type INFO HASH_PKGMGR_NOT_SPEC "${HASH_FUNC}"
fi
else
display --to LOG --type INFO HASH_PKGMGR_NOT_SPEC "${HASH_FUNC}"
fi
else
display --to LOG --type INFO HASH_PKGMGR "${PKGMGR}"
case "${PKGMGR}" in
RPM)
display --to LOG --type INFO FOUND_CMD 'rpm' "${RPM_CMD}"
;;
DPKG)
if [ -z "`echo \"${DPKG_CMD}\" | grep '/dpkg$'`" ]; then
display --to LOG --type INFO FOUND_CMD 'dpkg-query' "${DPKG_CMD}"
else
display --to LOG --type INFO FOUND_CMD 'dpkg' "${DPKG_CMD}"
fi
display --to LOG --type INFO HASH_PKGMGR_MD5 "${PKGMGR_MD5_HASH}"
;;
BSD)
display --to LOG --type INFO FOUND_CMD 'pkg-info' "${PKG_CMD}"
display --to LOG --type INFO HASH_PKGMGR_MD5 "${PKGMGR_MD5_HASH}"
;;
SOLARIS)
if [ $USE_SUNSUM -eq 1 ]; then
display --to LOG --type INFO HASH_PKGMGR_SUM
display --to LOG --type INFO FOUND_CMD 'sum' "${SUM_CMD}"
fi
;;
esac
fi
fi
fi
RKHTMPVAR=0
test $CHECK -eq 1 && `check_test attributes` && RKHTMPVAR=1
if [ $RKHTMPVAR -eq 1 ]; then
if [ "${OLD_ATTRUPD}" = "Disabled" ]; then
display --to LOG --type INFO ATTRUPD_OLD_DISABLED
elif [ "${OLD_ATTRUPD}" = "Nostatcmd" ]; then
display --to LOG --type INFO ATTRUPD_OLD_NOSTATCMD
else
display --to LOG --type INFO ATTRUPD_OLD_OK
fi
fi
if [ $PROP_UPDATE -eq 1 ]; then
if ! `check_test attributes` && test $ENDIS_OPT -eq 0; then
display --to LOG --type INFO ATTRUPD_DISABLED
elif [ -z "${STAT_CMD}" ]; then
display --to LOG --type INFO ATTRUPD_NOSTATCMD
else
display --to LOG --type INFO ATTRUPD_OK
fi
fi
if [ $CHECK -eq 1 ]; then
display --to LOG --type INFO ENABLED_TESTS "${ENABLE_TESTS}"
display --to LOG --type INFO DISABLED_TESTS "${DISABLE_TESTS}"
fi
if `check_test properties` || test $PROP_UPDATE -eq 1; then
if [ -n "${USER_FILE_LIST}" ]; then
display --to LOG --type INFO USER_FILE_LIST
IFS=$IFSNL
for FNAME in ${USER_FILE_LIST}; do
display --to LOG --type PLAIN --log-indent 6 NAME "`name2text \"${FNAME}\"`"
done
IFS=$RKHIFS
fi
if [ -n "${USER_SIMPLE_FILE_LIST}" ]; then
display --to LOG --type INFO USER_CMD_LIST
IFS=$IFSNL
for FNAME in ${USER_SIMPLE_FILE_LIST}; do
display --to LOG --type PLAIN --log-indent 6 NAME "`name2text \"${FNAME}\"`"
done
IFS=$RKHIFS
fi
if [ -n "${USER_DIR_LIST}" ]; then
display --to LOG --type INFO USER_DIR_LIST
IFS=$IFSNL
for FNAME in ${USER_DIR_LIST}; do
display --to LOG --type PLAIN --log-indent 6 NAME "`name2text \"${FNAME}\"`"
done
IFS=$RKHIFS
fi
if [ -n "${USER_EXCLUDE_PROP}" ]; then
display --to LOG --type INFO USER_EXCLUDE_PROP
IFS=$IFSNL
for FNAME in ${USER_EXCLUDE_PROP}; do
display --to LOG --type PLAIN --log-indent 6 NAME "`name2text \"${FNAME}\"`"
done
IFS=$RKHIFS
fi
fi
if [ $UPDATE -eq 1 -o $VERSIONCHECK -eq 1 ]; then
if [ $ROTATE_MIRRORS -eq 0 ]; then
display --to LOG --type INFO CONFIG_NO_ROTATE_MIRRORS
else
display --to LOG --type INFO CONFIG_ROTATE_MIRRORS
fi
if [ $MIRRORS_MODE -eq 0 ]; then
display --to LOG --type INFO CONFIG_MIRRORS_MODE0
elif [ $MIRRORS_MODE -eq 1 ]; then
display --to LOG --type INFO CONFIG_MIRRORS_MODE1
else
display --to LOG --type INFO CONFIG_MIRRORS_MODE2
fi
if [ $UPDATE -eq 1 ]; then
if [ $UPDATE_MIRRORS -eq 0 ]; then
display --to LOG --type INFO CONFIG_NO_UPDATE_MIRRORS
else
display --to LOG --type INFO CONFIG_UPDATE_MIRRORS
fi
fi
fi
if [ $NOLOG -eq 0 ]; then
test $CHECK -eq 0 -o $SHOW_SUMMARY -eq 0 && display --to LOG --type INFO CONFIG_LOG_FILE "${RKHLOGFILE}"
test $VERBOSE_LOGGING -eq 0 && display --to LOG --type INFO CONFIG_NO_VL
test $APPEND_LOG -eq 1 && display --to LOG --type INFO CONFIG_APPEND_LOG
test $COPY_LOG_ON_ERROR -eq 1 && display --to LOG --type INFO CONFIG_COPY_LOG
fi
if [ $CHECK -eq 1 ]; then
if [ -n "${KSYMS_FILE}" ]; then
display --to LOG --type INFO KSYMS_FOUND "${KSYMS_FILE}"
elif [ -f "/proc/ksyms" ]; then
display --to LOG --type INFO KSYMS_FOUND '/proc/ksyms'
display --to LOG --type INFO KSYMS_UNAVAIL
elif [ -f "/proc/kallsyms" ]; then
display --to LOG --type INFO KSYMS_FOUND '/proc/kallsyms'
display --to LOG --type INFO KSYMS_UNAVAIL
else
display --to LOG --type INFO KSYMS_MISSING
fi
test $SHOW_SUMMARY -eq 0 && display --to LOG --type INFO CONFIG_NO_SHOW_SUMMARY
#
# To use syslog we must have the logger command present.
#
if [ -n "${USE_SYSLOG}" ]; then
if [ "${USE_SYSLOG}" = "none" ]; then
USE_SYSLOG=""
display --to LOG --type INFO SYSLOG_DISABLED
else
LOGGER_CMD=`find_cmd logger`
if [ -n "${LOGGER_CMD}" ]; then
display --to LOG --type INFO SYSLOG_ENABLED "${USE_SYSLOG}"
else
USE_SYSLOG=""
display --to LOG --type INFO SYSLOG_NO_LOGGER
fi
fi
fi
if [ "${EPOCH_DATE_CMD}" = "NONE" ]; then
:
elif [ -n "${EPOCH_DATE_CMD}" ]; then
display --to LOG --type INFO FILE_PROP_EPOCH_DATE_CMD "${EPOCH_DATE_CMD}"
elif [ -n "${PERL_CMD}" ]; then
display --to LOG --type INFO FILE_PROP_EPOCH_DATE_CMD "${PERL_CMD}"
fi
#
# If the user wants to run the file properties checks, and the
# rkhunter.dat file exists, then check the O/S info. If the
# rkhunter.dat file does not exist, then this will be logged
# later on.
#
if `check_test properties`; then
if [ -s "${RKHDAT_FILE}" ]; then
#
# We perform a simple check on some of the stored
# O/S information, and compare it to the current
# info. Basically we are just seeing if the system
# has changed at all because it could affect the
# file properties checks.
#
rkh_dat_get_os_info
check_os_info
fi
fi
fi
if [ $USE_LOCKING -eq 1 ]; then
display --to LOG --type INFO LOCK_USED "$LOCK_TIMEOUT"
else
display --to LOG --type INFO LOCK_UNUSED
fi
######################################################################
#
# Start of program actions and checks
#
######################################################################
#
# We can now start to run the actions the user has requested on
# the command-line. We run the update type commands first before
# doing any full system check.
#
#
# The user wants to update the O/S and the file properties data.
#
test $PROP_UPDATE -eq 1 && do_prop_update
#
# The user wants to update the supplied RKH *.dat files.
#
test $UPDATE -eq 1 && do_update
#
# The user wants to check for the latest program version.
#
test $VERSIONCHECK -eq 1 && do_versioncheck
#
# The user wants to check the local system for anomalies.
#
test $CHECK -eq 1 -o $ENDIS_OPT -eq 1 && do_system_check
#
# If there were errors or warnings, and the
# log file is to be copied, then log it.
#
COPIEDLOG=""
if [ $RET_CODE -gt 0 -o $WARNING_COUNT -gt 0 ]; then
if [ $COPY_LOG_ON_ERROR -eq 1 -a $NOLOG -eq 0 ]; then
COPIEDLOG="${RKHLOGFILE}.`date +%Y-%m-%d_%H:%M:%S`"
display --to LOG --type INFO --nl SUMMARY_LOGFILE_COPIED "${COPIEDLOG}"
fi
fi
display --to LOG --type INFO --nl RKH_ENDDATE "`date`"
#
# Now actually copy the log file.
#
test -n "${COPIEDLOG}" && cp -p "${RKHLOGFILE}" "${COPIEDLOG}"
#
# If the user asked to see the logfile, then show it.
#
test $CATLOGFILE -eq 1 && cat "${RKHLOGFILE}"
IFS=$ORIGIFS
exit $RET_CODE
|