Skip to content

Commit

Permalink
v2.0.0 staging to main
Browse files Browse the repository at this point in the history
v2.0.0 staging to main
  • Loading branch information
HFDan committed Feb 24, 2022
2 parents 81d4365 + 15e9eee commit eb0c50d
Show file tree
Hide file tree
Showing 37 changed files with 478 additions and 157 deletions.
27 changes: 27 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
BasedOnStyle: Google
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveMacros: "true"
AlignConsecutiveAssignments: "false"
AlignConsecutiveDeclarations: "false"
AlignEscapedNewlines: Left
CompactNamespaces: "false"
ConstructorInitializerIndentWidth: "4"
ContinuationIndentWidth: "4"
Cpp11BracedListStyle: "true"
FixNamespaceComments: "true"
IndentWidth: "4"
NamespaceIndentation: All
ObjCBlockIndentWidth: "4"
PointerAlignment: Left
SortIncludes: "true"
SortUsingDeclarations: "true"
SpaceAfterLogicalNot: "false"
SpaceBeforeParens: ControlStatements
SpacesBeforeTrailingComments: "2"
SpacesInSquareBrackets: "false"
Standard: Auto
TabWidth: "4"
UseTab: Always
BinPackArguments: "false"
BinPackParameters: "false"
48 changes: 48 additions & 0 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CD

on:
push:
tags:
- "v*"

jobs:
tagged-release:
name: "Tagged Release"
runs-on: "windows-latest"

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2.3.2
- name: Setup meson and ninja
run: |
pip install ninja
pip install meson
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64
- name: Build x64 artifacts
run: |
meson setup Build-x86_64 -Ddefault_library=static --buildtype release -DCD=true
cd Build-x86_64
ninja
cd ..
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64_x86
- name: Build i686 artifacts
run: |
meson setup Build-i686 -Ddefault_library=static --buildtype release -DCD=true -DCD_32BIT=true
cd Build-i686
ninja
cd ..
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
draft: true
files: |
Build-x64/fake-cmd_x86_64.exe
Build-i686/fake-cmd_i686.exe
45 changes: 12 additions & 33 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,18 @@ on:
pull_request:
branches: [ main ]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
jobs:
build-and-test:
runs-on: windows-latest

steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive

- name: Debug stuff
run: cat CMakeLists.txt

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -Dgtest_force_shared_crt=ON

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}}

- uses: actions/checkout@v2
- uses: actions/setup-python@v2.3.2
- uses: ilammy/msvc-dev-cmd@v1
- name: Debug build
run: |
pip install meson
pip install ninja
meson setup Build -Ddefault_library=static --buildtype debug
cd Build
ninja test
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

23 changes: 0 additions & 23 deletions CMakeLists.txt

This file was deleted.

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@
# Fake-CMD

## Description

A (modular) program to confuse scammers. Perfect for scambaiting.

## Contributing

Anyone is free to create modules, as long as their license is _**MPL-2.0**_.

### How to contribute?

Check the [wiki](https://github.com/HFDan/Fake-CMD/wiki).

# Third-party licenses

- [GTest](https://github.com/google/googletest), \(BSD-3-Clause License\)
- [Lua](https://lua.org), \(MIT License\)

### Branches
- main -> Latest stable release
- develop -> Newest branch. Active development. Possibly unstable
Expand Down
1 change: 0 additions & 1 deletion lib/googletest
Submodule googletest deleted from 830602
1 change: 0 additions & 1 deletion lib/utility/CMakeLists.txt

This file was deleted.

16 changes: 0 additions & 16 deletions lib/utility/utility.cpp

This file was deleted.

8 changes: 0 additions & 8 deletions lib/utility/utility.h

This file was deleted.

46 changes: 46 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
project('fake-cmd', 'cpp', default_options:['c_std=c11', 'cpp_std=c++20'], version: '2.0.0')

if get_option('CD_32BIT')
add_global_arguments('-m32"', language : 'c')
add_global_arguments('-m32', language : 'cpp')
endif

if host_machine.system() == 'windows'
add_global_arguments('-DCLEAR_COMMAND="cls"', language : 'c')
add_global_arguments('-DCLEAR_COMMAND="cls"', language : 'cpp')
endif

if host_machine.system() == 'linux'
add_global_arguments('-DCLEAR_COMMAND="clear"', language : 'c')
add_global_arguments('-DCLEAR_COMMAND="clear"', language : 'cpp')
endif

if get_option('buildtype').startswith('debug')
add_project_arguments('-DDEBUG', language : 'cpp')
add_project_arguments('-DDEBUG', language : 'c')
endif

thread_dep = dependency('threads')
gtest = subproject('gtest')
lua = subproject('lua')

src_libmodules = ['src/modules/modules.cpp', 'src/modules/netstat.cpp', 'src/modules/syskey.cpp', 'src/modules/tree.cpp', 'src/modules/runtime_modules.cpp', 'src/lua/extensions/lua_fakecmd.cpp', 'src/modules/help.cpp']
libmodules = static_library('libmodules', src_libmodules, dependencies: [thread_dep, dependency('lua-5.4')], include_directories: include_directories('src/'))

src_main = ['src/main.cpp', 'src/utility/utility.cpp']
if get_option('CD') == true
if get_option('CD_32BIT') == true
main_name = 'fake-cmd_i686'
else
main_name = 'fake-cmd_x86_64'
endif
else
main_name = 'fake-cmd_' + host_machine.cpu()
endif

fakecmd = executable(main_name, src_main, dependencies: [thread_dep], include_directories: include_directories('src/'), link_with: [libmodules])
libfakecmd = static_library('libfakecmd', src_main, dependencies: [thread_dep], include_directories: include_directories('src/'), link_with: [libmodules])

src_monolithictest = ['test/monolithicTest.cpp']
monolithic_test = executable('monolithictest', src_monolithictest, dependencies: [dependency('gtest_main')], link_with: [libmodules], include_directories: include_directories('src/modules'))
test('monolithic test', monolithic_test)
2 changes: 2 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
option('CD_32BIT', type: 'boolean', value: false)
option('CD', type: 'boolean', value: false)
23 changes: 23 additions & 0 deletions src/debug.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#ifdef DEBUG
#include <cstdio>
#include <ctime>
#define FCMD_DEBUGMSG(source, severity, msg, ...) \
switch (severity) { \
case 0: \
printf("[INFO] [%s]: " msg "\n", source, __VA_ARGS__); \
break; \
\
case 1: \
printf("[WARNING] [%s]: " msg "\n", source, __VA_ARGS__); \
break; \
\
case 2: \
fprintf(stderr, "[ERROR] [%s]: " msg "\n", source, __VA_ARGS__); \
break; \
}

#else
#define FCMD_DEBUGMSG(...)
#endif
14 changes: 14 additions & 0 deletions src/lua/extensions/lua_fakecmd.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <lua/extensions/lua_fakecmd.h>

#include <cstdlib>
#include <lua.hpp>

static int l_clear(lua_State* L) {
system("clear");
return 0;
}

void l_fakecmd_loadluaextensions(lua_State* L) {
lua_pushcfunction(L, l_clear);
lua_setglobal(L, CLEAR_COMMAND);
}
4 changes: 4 additions & 0 deletions src/lua/extensions/lua_fakecmd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once
#include <lua.hpp>

void l_fakecmd_loadluaextensions(lua_State* L);
5 changes: 5 additions & 0 deletions src/lua/sample/clear.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
--[[
This is a module that clears the screen.
--]]

clear() -- Function specific to fakecmd (part of extension)
19 changes: 19 additions & 0 deletions src/lua/sample/download.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--[[
This downloads a file from the internet.
It is also proof as to why you should only install runtime modules
from trusted sources.
Note: It doesn't work without lua-socket installed. This is intended behavior.
I will NOT include lua-socket with fake-cmd, for this exact reason
--]]

local http = require("socket.http")

local res, err = http.request("https://i.ytimg.com/vi/9SklO4OFEJI/maxresdefault.jpg")

if not res then error(err) end

-- saves response to file
local f = assert(io.open("sussy.jpg", "wb"))
f:write(res)
f:close()
8 changes: 8 additions & 0 deletions src/lua/sample/file.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--[[
This module creates a file in the directory where fakecmd is installed.
--]]

local file = io.open("amogus.txt", "a")

file:write("Dababy school of sussy amogus")
file:close()
5 changes: 5 additions & 0 deletions src/lua/sample/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/bash

for f in ./*.lua; do
cp "${f}" "${HOME}/.fake_cmd/${f}"
done
13 changes: 13 additions & 0 deletions src/lua/sample/neo.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--[[
This module reads a name from the user, then prints:
"Hello, $USER"
If no name provided, prints "Hello, neo..."
--]]

local name = io.read()

if name ~= "" then
print("Hello, "..name.."...")
else
print("Hello, neo...")
end
Loading

0 comments on commit eb0c50d

Please sign in to comment.